diff --git a/CalamityMod.cs b/CalamityMod.cs index f754e0f778..717d20194b 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -66,6 +66,7 @@ using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; +using CalamityMod.Tiles.LivingFire; using CalamityMod.Skies; using CalamityMod.UI; using CalamityMod.World; @@ -194,6 +195,7 @@ namespace CalamityMod public static List highTestFishList; public static List flamethrowerList; public static List forceItemList; + public static List livingFireBlockList; public static List zombieList; public static List demonEyeList; @@ -417,6 +419,7 @@ namespace CalamityMod highTestFishList = null; flamethrowerList = null; forceItemList = null; + livingFireBlockList = null; zombieList = null; demonEyeList = null; @@ -2346,6 +2349,19 @@ namespace CalamityMod ItemID.SuperHealingPotion }; + livingFireBlockList = new List() + { + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + TileID.LivingFire, + TileID.LivingCursedFire, + TileID.LivingDemonFire, + TileID.LivingFrostFire, + TileID.LivingIchor, + TileID.LivingUltrabrightFire + }; + zombieList = new List() { NPCID.Zombie, @@ -3732,6 +3748,7 @@ namespace CalamityMod case CalamityModMessageType.AcidRainSync: CalamityWorld.rainingAcid = reader.ReadBoolean(); CalamityWorld.acidRainPoints = reader.ReadInt32(); + CalamityWorld.timeSinceAcidRainKill = reader.ReadInt32(); break; case CalamityModMessageType.AcidRainUIDrawFadeSync: CalamityWorld.acidRainExtraDrawTime = reader.ReadInt32(); diff --git a/Events/AcidRainEvent.cs b/Events/AcidRainEvent.cs index dccee03419..4d72473cef 100644 --- a/Events/AcidRainEvent.cs +++ b/Events/AcidRainEvent.cs @@ -34,6 +34,8 @@ namespace CalamityMod.Events // A partially bright pale-ish cyan with a hint of yellow. public static readonly Color TextColor = new Color(115, 194, 147); + public const int InvasionNoKillPersistTime = 14400; // How long the invasion persists, in frames, if nothing is killed. + public const float BloodwormSpawnRate = 0.1f; // Not a readonly collection so that if anyone else wants to add stuff in here with their own mod, they can. @@ -167,17 +169,16 @@ namespace CalamityMod.Events Main.numClouds = Main.numCloudsTemp; Main.windSpeedTemp = 0.72f; Main.windSpeedSet = Main.windSpeedTemp; - Main.weatherCounter = 600; + Main.weatherCounter = 60 * 60 * 10; // 10 minutes of rain. Remember, once the rain goes away, so does the invasion. + Main.rainTime = Main.weatherCounter; Main.maxRaining = 0.89f; CalamityWorld.forcedDownpourWithTear = true; CalamityMod.UpdateServerBoolean(); } - if (CalamityWorld.startAcidicDownpour) - { - Main.raining = true; - } CalamityWorld.triedToSummonOldDuke = false; + CalamityWorld.timeSinceAcidRainKill = 0; // Reset the kill cooldown, just in case. } + UpdateInvasion(); BroadcastEventText("Mods.CalamityMod.AcidRainStart"); // A toxic downpour falls over the wasteland seas! } @@ -222,6 +223,7 @@ namespace CalamityMod.Events netMessage.Write((byte)CalamityModMessageType.AcidRainSync); netMessage.Write(CalamityWorld.rainingAcid); netMessage.Write(CalamityWorld.acidRainPoints); + netMessage.Write(CalamityWorld.timeSinceAcidRainKill); netMessage.Send(); } if (Main.netMode == NetmodeID.Server) diff --git a/Items/Accessories/BrokenWaterFilter.cs b/Items/Accessories/BrokenWaterFilter.cs index 83401f1c0f..6778deaeec 100644 --- a/Items/Accessories/BrokenWaterFilter.cs +++ b/Items/Accessories/BrokenWaterFilter.cs @@ -27,7 +27,6 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 1); recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddRecipeGroup("IronBar", 10); recipe.AddTile(TileID.Anvils); diff --git a/Items/Accessories/RustyMedallion.cs b/Items/Accessories/RustyMedallion.cs index 9a8f099efb..e77b0415f5 100644 --- a/Items/Accessories/RustyMedallion.cs +++ b/Items/Accessories/RustyMedallion.cs @@ -31,7 +31,6 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 1); recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddRecipeGroup("IronBar", 10); recipe.AddTile(TileID.Anvils); diff --git a/Items/Accessories/Wings/SoulofCryogen.cs b/Items/Accessories/Wings/SoulofCryogen.cs index ed641c39f5..615bf881f3 100644 --- a/Items/Accessories/Wings/SoulofCryogen.cs +++ b/Items/Accessories/Wings/SoulofCryogen.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Items.Accessories.Wings { if (player.controlJump && !player.jumpAgainCloud && player.jump == 0 && player.velocity.Y != 0f && !player.mount.Active && !player.mount.Cart) { - int p = Projectile.NewProjectile(player.Center.X, player.Center.Y, player.velocity.X * 0f, 2f, ModContent.ProjectileType(), (int)(25 * player.AverageDamage()), 3f, player.whoAmI); + int p = Projectile.NewProjectile(player.Center.X, player.Center.Y, player.velocity.X * 0f, 2f, ModContent.ProjectileType(), (int)(25 * player.AverageDamage()), 3f, player.whoAmI, 1f); Main.projectile[p].Calamity().forceTypeless = true; Main.projectile[p].frame = Main.rand.Next(5); modPlayer.icicleCooldown = 10; diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index fc2c12ac82..52ee2ba370 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -81,6 +81,12 @@ namespace CalamityMod.Items myClone.StealthGenBonus = StealthGenBonus; return myClone; } + + public override bool NewPreReforge(Item item) + { + StealthGenBonus = 1f; + return true; + } #endregion #region SetDefaults @@ -129,7 +135,7 @@ namespace CalamityMod.Items else if (item.type == ItemID.BlizzardStaff) item.damage = (int)(item.damage * 0.7); else if (item.type == ItemID.LaserMachinegun) - item.damage = (int)(item.damage * 0.6); + item.damage = (int)(item.damage * 0.65); else if (item.type == ItemID.StardustDragonStaff) item.damage = (int)(item.damage * 0.5); @@ -2805,7 +2811,7 @@ Provides heat and cold protection in Death Mode"; DropHelper.DropItemChance(player, ModContent.ItemType(), 3); DropHelper.DropItemChance(player, ModContent.ItemType(), 3); DropHelper.DropItemChance(player, ModContent.ItemType(), 4); - DropHelper.DropItemFromSetChance(player, 5, ItemID.CorruptionKey, ItemID.CrimsonKey); + DropHelper.DropItemFromSetChance(player, 0.2f, ItemID.CorruptionKey, ItemID.CrimsonKey); DropHelper.DropItemCondition(player, ModContent.ItemType(), !CalamityWorld.demonMode); // Demon Trophy break; diff --git a/Items/Fishing/AstralCatches/AstralCrate.cs b/Items/Fishing/AstralCatches/AstralCrate.cs index 2e29d34eed..1011abd771 100644 --- a/Items/Fishing/AstralCatches/AstralCrate.cs +++ b/Items/Fishing/AstralCatches/AstralCrate.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Items.Fishing.AstralCatches } // Weapons - DropHelper.DropItemFromSetCondition(player, CalamityWorld.downedAstrageldon, + DropHelper.DropItemFromSetCondition(player, CalamityWorld.downedAstrageldon, 0.2f, ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), diff --git a/Items/Fishing/AstralCatches/PolarisParrotfish.cs b/Items/Fishing/AstralCatches/PolarisParrotfish.cs index 8a313d2556..47c23f02f7 100644 --- a/Items/Fishing/AstralCatches/PolarisParrotfish.cs +++ b/Items/Fishing/AstralCatches/PolarisParrotfish.cs @@ -20,12 +20,12 @@ namespace CalamityMod.Items.Fishing.AstralCatches public override void SetDefaults() { - item.damage = 55; + item.damage = 50; item.ranged = true; item.width = 38; item.height = 34; - item.useTime = 20; - item.useAnimation = 20; + item.useTime = 21; + item.useAnimation = 21; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 2.25f; @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Fishing.AstralCatches } else if (modPlayer.polarisBoostTwo) //Splits on enemy or tile hits { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), (int)((double)damage * 1.25), knockBack, player.whoAmI, 0f, 1f); + Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), (int)(damage * 1.25), knockBack, player.whoAmI, 0f, 1f); return false; } return true; diff --git a/Items/Fishing/SulphurCatches/AbyssalCrate.cs b/Items/Fishing/SulphurCatches/AbyssalCrate.cs index 94230ce88a..feee04676e 100644 --- a/Items/Fishing/SulphurCatches/AbyssalCrate.cs +++ b/Items/Fishing/SulphurCatches/AbyssalCrate.cs @@ -77,14 +77,14 @@ namespace CalamityMod.Items.Fishing.SulphurCatches } // Weapons - DropHelper.DropItemFromSetCondition(player, NPC.downedBoss3, + DropHelper.DropItemFromSetCondition(player, NPC.downedBoss3, 0.2f, ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType()); - DropHelper.DropItemFromSetCondition(player, CalamityWorld.downedAquaticScourgeAcidRain, + DropHelper.DropItemFromSetCondition(player, CalamityWorld.downedAquaticScourgeAcidRain, 0.2f, ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), @@ -94,7 +94,7 @@ namespace CalamityMod.Items.Fishing.SulphurCatches ModContent.ItemType()); // Equipment - DropHelper.DropItemFromSetCondition(player, NPC.downedBoss3, + DropHelper.DropItemFromSetCondition(player, NPC.downedBoss3, 0.4f, ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), diff --git a/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs b/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs index 4df71a1f85..ca9397f4e0 100644 --- a/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs +++ b/Items/Fishing/SunkenSeaCatches/SunkenCrate.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches } // Weapons - DropHelper.DropItemFromSetCondition(player, CalamityWorld.downedCLAM && Main.hardMode, + DropHelper.DropItemFromSetCondition(player, CalamityWorld.downedCLAM && Main.hardMode, 0.2f, ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), diff --git a/Items/Placeables/Furniture/EffigyOfDecay.cs b/Items/Placeables/Furniture/EffigyOfDecay.cs index e748104277..5f3a3c6292 100644 --- a/Items/Placeables/Furniture/EffigyOfDecay.cs +++ b/Items/Placeables/Furniture/EffigyOfDecay.cs @@ -34,7 +34,6 @@ namespace CalamityMod.Items.Placeables.Furniture public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 1); recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddRecipeGroup("IronBar", 10); recipe.AddTile(TileID.Anvils); diff --git a/Items/Placeables/Furniture/RustyChest.cs b/Items/Placeables/Furniture/RustyChest.cs index ebd21d9305..768833221d 100644 --- a/Items/Placeables/Furniture/RustyChest.cs +++ b/Items/Placeables/Furniture/RustyChest.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Placeables.Furniture item.useStyle = ItemUseStyleID.SwingThrow; item.consumable = true; item.value = 500; - item.createTile = ModContent.TileType(); + item.createTile = ModContent.TileType(); } public override void AddRecipes() { diff --git a/Items/RustyLockpick.cs b/Items/RustyLockpick.cs deleted file mode 100644 index 3598f8959a..0000000000 --- a/Items/RustyLockpick.cs +++ /dev/null @@ -1,30 +0,0 @@ -using CalamityMod.Items.Materials; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Items -{ - public class RustyLockpick : ModItem - { - public override void SetStaticDefaults() - { - Tooltip.SetDefault("Opens locked rusty chests"); - } - - public override void SetDefaults() - { - item.width = 14; - item.height = 28; - item.maxStack = 99; - item.rare = 1; - item.value = CalamityGlobalItem.Rarity1BuyPrice; - } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } -} diff --git a/Items/RustyLockpick.png b/Items/RustyLockpick.png deleted file mode 100644 index 4281306709..0000000000 Binary files a/Items/RustyLockpick.png and /dev/null differ diff --git a/Items/Tools/ClimateChange/TorrentialTear.cs b/Items/Tools/ClimateChange/TorrentialTear.cs index c0ff3c1f21..a23a70fef2 100644 --- a/Items/Tools/ClimateChange/TorrentialTear.cs +++ b/Items/Tools/ClimateChange/TorrentialTear.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Tools.ClimateChange public override bool CanUseItem(Player player) { - return !Main.slimeRain && (Main.rainTime > 3600 || !CalamityWorld.death || !Main.raining); + return !Main.slimeRain && (Main.rainTime > 3600 || !CalamityWorld.death || !Main.raining || CalamityWorld.rainingAcid); } public override bool UseItem(Player player) @@ -48,22 +48,10 @@ namespace CalamityMod.Items.Tools.ClimateChange Main.rainTime = 3600; AdjustRainSeverity(true); } - if (CalamityWorld.rainingAcid) - { - CalamityWorld.acidRainPoints = 0; - CalamityWorld.triedToSummonOldDuke = false; - AcidRainEvent.UpdateInvasion(false); - } } else { Main.raining = false; - if (CalamityWorld.rainingAcid) - { - CalamityWorld.acidRainPoints = 0; - CalamityWorld.triedToSummonOldDuke = false; - AcidRainEvent.UpdateInvasion(false); - } } CalamityMod.UpdateServerBoolean(); diff --git a/Items/Weapons/Magic/Hematemesis.cs b/Items/Weapons/Magic/Hematemesis.cs index 2750cfd9d1..7f12e1787a 100644 --- a/Items/Weapons/Magic/Hematemesis.cs +++ b/Items/Weapons/Magic/Hematemesis.cs @@ -17,14 +17,14 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 90; + item.damage = 75; item.magic = true; item.mana = 14; item.rare = 8; item.width = 48; item.height = 54; - item.useTime = 20; - item.useAnimation = 20; + item.useTime = 22; + item.useAnimation = 22; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 3.75f; @@ -35,17 +35,14 @@ namespace CalamityMod.Items.Weapons.Magic item.shootSpeed = 10f; } - public override Vector2? HoldoutOrigin() - { - return new Vector2(15, 15); - } + public override Vector2? HoldoutOrigin() => new Vector2(15, 15); public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { position = Main.MouseWorld; for (int x = 0; x < 10; x++) { - Projectile.NewProjectile(position.X + (float)Main.rand.Next(-150, 150), position.Y + 600f, 0f, -10f, type, damage, knockBack, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(position.X + (float)Main.rand.Next(-150, 150), position.Y + 600f, 0f, -10f, type, damage, knockBack, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Magic/ParasiticSceptor.cs b/Items/Weapons/Magic/ParasiticSceptor.cs index 50b86961e5..a562d2398f 100644 --- a/Items/Weapons/Magic/ParasiticSceptor.cs +++ b/Items/Weapons/Magic/ParasiticSceptor.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Weapons.Magic { public override void SetStaticDefaults() { - DisplayName.SetDefault("Parasitic Sceptor"); + DisplayName.SetDefault("Parasitic Scepter"); Tooltip.SetDefault("Fires a spread of water leeches that latch onto enemies, dealing a stacking damage over time"); Item.staff[item.type] = true; } @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Magic item.width = item.height = 52; item.UseSound = SoundID.Item46; item.noMelee = true; - item.useStyle = 5; + item.useStyle = ItemUseStyleID.HoldingOut; item.rare = 2; item.value = CalamityGlobalItem.Rarity2BuyPrice; } @@ -38,28 +38,28 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - float speed = item.shootSpeed; - Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float xDist = Main.mouseX + Main.screenPosition.X - playerPos.X; - float yDist = Main.mouseY + Main.screenPosition.Y - playerPos.Y; - if (player.gravDir == -1f) - { - yDist = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - playerPos.Y; - } + float speed = item.shootSpeed; + Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float xDist = Main.mouseX + Main.screenPosition.X - playerPos.X; + float yDist = Main.mouseY + Main.screenPosition.Y - playerPos.Y; + if (player.gravDir == -1f) + { + yDist = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - playerPos.Y; + } Vector2 vector = new Vector2(xDist, yDist); float speedMult = vector.Length(); - if ((float.IsNaN(xDist) && float.IsNaN(yDist)) || (xDist == 0f && yDist == 0f)) - { - xDist = player.direction; - yDist = 0f; - speedMult = speed; - } - else - { - speedMult = speed / speedMult; - } - xDist *= speedMult; - yDist *= speedMult; + if ((float.IsNaN(xDist) && float.IsNaN(yDist)) || (xDist == 0f && yDist == 0f)) + { + xDist = player.direction; + yDist = 0f; + speedMult = speed; + } + else + { + speedMult = speed / speedMult; + } + xDist *= speedMult; + yDist *= speedMult; int leechAmt = 2; if (Main.rand.NextBool(3)) { @@ -73,21 +73,21 @@ namespace CalamityMod.Items.Weapons.Magic { leechAmt ++; } - for (int i = 0; i < leechAmt; i++) - { - float xVec = xDist; - float yVec = yDist; - float spreadMult = 0.05f * i; - xVec += Main.rand.NextFloat(-25f, 25f) * spreadMult; - yVec += Main.rand.NextFloat(-25f, 25f) * spreadMult; + for (int i = 0; i < leechAmt; i++) + { + float xVec = xDist; + float yVec = yDist; + float spreadMult = 0.05f * i; + xVec += Main.rand.NextFloat(-25f, 25f) * spreadMult; + yVec += Main.rand.NextFloat(-25f, 25f) * spreadMult; Vector2 directionToShoot = new Vector2(xVec, yVec); speedMult = directionToShoot.Length(); - speedMult = speed / speedMult; - xVec *= speedMult; - yVec *= speedMult; - directionToShoot = new Vector2(xVec, yVec); - Projectile.NewProjectile(playerPos, directionToShoot, type, damage, knockBack, player.whoAmI, 0f, 0f); - } + speedMult = speed / speedMult; + xVec *= speedMult; + yVec *= speedMult; + directionToShoot = new Vector2(xVec, yVec); + Projectile.NewProjectile(playerPos, directionToShoot, type, damage, knockBack, player.whoAmI, 0f, 0f); + } return false; } } diff --git a/Items/Weapons/Magic/RelicofRuin.cs b/Items/Weapons/Magic/RelicofRuin.cs index c107657fd3..30cfe57299 100644 --- a/Items/Weapons/Magic/RelicofRuin.cs +++ b/Items/Weapons/Magic/RelicofRuin.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 26; + item.damage = 20; item.magic = true; item.mana = 16; item.width = 28; @@ -37,12 +37,11 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - float spread = 22.5f * 0.0174f; + float spread = 22.5f * 0.01f * MathHelper.PiOver2; double startAngle = Math.Atan2(speedX, speedY) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; - int i; - for (i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; Projectile.NewProjectile(position.X, position.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), type, damage, knockBack, Main.myPlayer); diff --git a/Items/Weapons/Magic/StormSpray.cs b/Items/Weapons/Magic/StormSpray.cs index 53db58ca5d..afa23b2fd0 100644 --- a/Items/Weapons/Magic/StormSpray.cs +++ b/Items/Weapons/Magic/StormSpray.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 18; + item.damage = 14; item.magic = true; item.mana = 8; item.width = 42; diff --git a/Items/Weapons/Magic/VividClarity.cs b/Items/Weapons/Magic/VividClarity.cs index add2d994d1..e3d625197c 100644 --- a/Items/Weapons/Magic/VividClarity.cs +++ b/Items/Weapons/Magic/VividClarity.cs @@ -50,29 +50,28 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num72 = item.shootSpeed; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - float f = Main.rand.NextFloat() * 6.28318548f; - float value12 = 20f; - float value13 = 60f; - Vector2 vector13 = vector2 + f.ToRotationVector2() * MathHelper.Lerp(value12, value13, Main.rand.NextFloat()); + Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float speed = item.shootSpeed; + float xPos = (float)Main.mouseX + Main.screenPosition.X - playerPos.X; + float yPos = (float)Main.mouseY + Main.screenPosition.Y - playerPos.Y; + float f = Main.rand.NextFloat() * MathHelper.TwoPi; + float sourceVariationLow = 20f; + float sourceVariationHigh = 60f; + Vector2 source = playerPos + f.ToRotationVector2() * MathHelper.Lerp(sourceVariationLow, sourceVariationHigh, Main.rand.NextFloat()); for (int num202 = 0; num202 < 50; num202++) { - vector13 = vector2 + f.ToRotationVector2() * MathHelper.Lerp(value12, value13, Main.rand.NextFloat()); - if (Collision.CanHit(vector2, 0, 0, vector13 + (vector13 - vector2).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) + source = playerPos + f.ToRotationVector2() * MathHelper.Lerp(sourceVariationLow, sourceVariationHigh, Main.rand.NextFloat()); + if (Collision.CanHit(playerPos, 0, 0, source + (source - playerPos).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) { break; } - f = Main.rand.NextFloat() * 6.28318548f; + f = Main.rand.NextFloat() * MathHelper.TwoPi; } - Vector2 mouseWorld = Main.MouseWorld; - Vector2 vector14 = mouseWorld - vector13; - Vector2 vector15 = new Vector2(num78, num79).SafeNormalize(Vector2.UnitY) * num72; - vector14 = vector14.SafeNormalize(vector15) * num72; - vector14 = Vector2.Lerp(vector14, vector15, 0.25f); - Projectile.NewProjectile(vector13, vector14, type, damage, knockBack, player.whoAmI, 0f, Main.rand.Next(3)); + Vector2 velocity = Main.MouseWorld - source; + Vector2 velocityVariation = new Vector2(xPos, yPos).SafeNormalize(Vector2.UnitY) * speed; + velocity = velocity.SafeNormalize(velocityVariation) * speed; + velocity = Vector2.Lerp(velocity, velocityVariation, 0.25f); + Projectile.NewProjectile(source, velocity, type, damage, knockBack, player.whoAmI, 0f, Main.rand.Next(3)); return false; } diff --git a/Items/Weapons/Magic/Waywasher.cs b/Items/Weapons/Magic/Waywasher.cs index f35c4a9e5b..bd7b32b3c8 100644 --- a/Items/Weapons/Magic/Waywasher.cs +++ b/Items/Weapons/Magic/Waywasher.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 20; + item.damage = 15; item.magic = true; item.mana = 4; item.width = 30; diff --git a/Items/Weapons/Melee/AstralScythe.cs b/Items/Weapons/Melee/AstralScythe.cs index 4fef76c126..2708359934 100644 --- a/Items/Weapons/Melee/AstralScythe.cs +++ b/Items/Weapons/Melee/AstralScythe.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.width = 56; item.height = 60; - item.damage = 95; + item.damage = 120; item.melee = true; item.useTurn = true; item.useAnimation = 20; @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, (int)(damage * 0.6), knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 0.6), knockBack, player.whoAmI, 0f, 0f); return false; } diff --git a/Items/Weapons/Melee/Murasama.cs b/Items/Weapons/Melee/Murasama.cs index 731ec4afcf..96056ec929 100644 --- a/Items/Weapons/Melee/Murasama.cs +++ b/Items/Weapons/Melee/Murasama.cs @@ -6,7 +6,6 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ID; namespace CalamityMod.Items.Weapons.Melee { diff --git a/Items/Weapons/Ranged/Butcher.cs b/Items/Weapons/Ranged/Butcher.cs index 92e04c5f64..95006a28b1 100644 --- a/Items/Weapons/Ranged/Butcher.cs +++ b/Items/Weapons/Ranged/Butcher.cs @@ -7,65 +7,54 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class Butcher : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Butcher"); - Tooltip.SetDefault("Fires faster and more accurately the longer you hold the trigger"); - } + public class Butcher : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Butcher"); + Tooltip.SetDefault("Fires faster and more accurately the longer you hold the trigger"); + } - public override void SetDefaults() - { - item.damage = 17; - item.width = 20; - item.height = 12; - item.useTime = 40; - item.useAnimation = 40; - item.useStyle = ItemUseStyleID.HoldingOut; - item.rare = 5; - item.knockBack = 1f; - item.value = Item.buyPrice(0, 36, 0, 0); - item.UseSound = SoundID.Item38; - item.noMelee = true; - item.noUseGraphic = true; - item.ranged = true; - item.channel = true; - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 12f; - item.useAmmo = 97; - } + public override void SetDefaults() + { + item.damage = 18; + item.width = 20; + item.height = 12; + item.useTime = 40; + item.useAnimation = 40; + item.useStyle = ItemUseStyleID.HoldingOut; + item.rare = 5; + item.knockBack = 1f; + item.value = Item.buyPrice(0, 36, 0, 0); + item.UseSound = SoundID.Item38; + item.noMelee = true; + item.noUseGraphic = true; + item.ranged = true; + item.channel = true; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 12f; + item.useAmmo = AmmoID.Bullet; + } - public override bool CanUseItem(Player player) - { - for (int i = 0; i < Main.projectile.Length; i++) - { - Projectile p = Main.projectile[i]; - if (p.active && p.type == ModContent.ProjectileType() && p.owner == player.whoAmI) - { - return false; - } - } - return true; - } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0.0f, 0.0f); - return false; - } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.Shotgun); - recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddIngredient(ItemID.IllegalGunParts); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.Shotgun); + recipe.AddIngredient(ItemID.HallowedBar, 5); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddIngredient(ItemID.IllegalGunParts); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/ClamorRifle.cs b/Items/Weapons/Ranged/ClamorRifle.cs index df03667b8f..5dd52eabfe 100644 --- a/Items/Weapons/Ranged/ClamorRifle.cs +++ b/Items/Weapons/Ranged/ClamorRifle.cs @@ -1,48 +1,46 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ID; namespace CalamityMod.Items.Weapons.Ranged { - public class ClamorRifle : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Clamor Rifle"); - Tooltip.SetDefault("Shoots homing energy bolts"); - } + public class ClamorRifle : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Clamor Rifle"); + Tooltip.SetDefault("Shoots homing energy bolts"); + } - public override void SetDefaults() - { - item.damage = 27; - item.ranged = true; - item.width = 64; - item.height = 30; - item.useTime = 13; - item.useAnimation = 13; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 2.5f; - item.value = Item.buyPrice(0, 36, 0, 0); - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBolt"); - item.autoReuse = true; - item.rare = 5; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 15f; - item.useAmmo = 97; - } + public override void SetDefaults() + { + item.damage = 23; + item.ranged = true; + item.width = 64; + item.height = 30; + item.useTime = 15; + item.useAnimation = 15; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 2.5f; + item.value = Item.buyPrice(0, 36, 0, 0); + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBolt"); + item.autoReuse = true; + item.rare = 5; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 15f; + item.useAmmo = AmmoID.Bullet; + } - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0.0f, 0.0f); - return false; - } - } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } + } } diff --git a/Items/Weapons/Ranged/DodusHandcannon.cs b/Items/Weapons/Ranged/DodusHandcannon.cs index dd8386ed70..b38fd89fff 100644 --- a/Items/Weapons/Ranged/DodusHandcannon.cs +++ b/Items/Weapons/Ranged/DodusHandcannon.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged { item.width = 70; item.height = 42; - item.damage = 450; + item.damage = 485; item.crit += 16; item.ranged = true; item.useTime = 30; diff --git a/Items/Weapons/Ranged/ElementalBlaster.cs b/Items/Weapons/Ranged/ElementalBlaster.cs index 272df50d82..18c979cc82 100644 --- a/Items/Weapons/Ranged/ElementalBlaster.cs +++ b/Items/Weapons/Ranged/ElementalBlaster.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 77; + item.damage = 66; item.ranged = true; item.width = 104; item.height = 42; diff --git a/Items/Weapons/Ranged/ElementalEruption.cs b/Items/Weapons/Ranged/ElementalEruption.cs index 2a1968c3f7..abf998ede5 100644 --- a/Items/Weapons/Ranged/ElementalEruption.cs +++ b/Items/Weapons/Ranged/ElementalEruption.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 40; + item.damage = 56; item.ranged = true; item.width = 64; item.height = 34; diff --git a/Items/Weapons/Ranged/HalleysInferno.cs b/Items/Weapons/Ranged/HalleysInferno.cs index 483079d09c..f313f0ea94 100644 --- a/Items/Weapons/Ranged/HalleysInferno.cs +++ b/Items/Weapons/Ranged/HalleysInferno.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 1750; + item.damage = 1666; item.crit += 20; item.ranged = true; item.width = 84; @@ -41,17 +41,9 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = 23; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-15, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-15, 0); - public override bool ConsumeAmmo(Player player) - { - if (Main.rand.Next(0, 100) < 50) - return false; - return true; - } + public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 50; public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/OpalStriker.cs b/Items/Weapons/Ranged/OpalStriker.cs index 2334271703..e02eeb06e3 100644 --- a/Items/Weapons/Ranged/OpalStriker.cs +++ b/Items/Weapons/Ranged/OpalStriker.cs @@ -6,51 +6,53 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class OpalStriker : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Opal Striker"); - Tooltip.SetDefault("Fires a string of opal strikes"); - } + public class OpalStriker : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Opal Striker"); + Tooltip.SetDefault("Fires a string of opal strikes"); + } - public override void SetDefaults() - { - item.damage = 9; - item.ranged = true; - item.width = 64; - item.height = 16; - item.useTime = 5; - item.reuseDelay = 25; - item.useAnimation = 20; - item.useStyle = ItemUseStyleID.HoldingOut; - item.noMelee = true; - item.knockBack = 0f; - item.value = Item.buyPrice(0, 2, 0, 0); - item.rare = 2; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/OpalStrike"); - item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 6f; - item.useAmmo = 97; - } + public override void SetDefaults() + { + item.damage = 9; + item.ranged = true; + item.width = 64; + item.height = 16; + item.useTime = 5; + item.reuseDelay = 25; + item.useAnimation = 20; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 0f; + item.value = Item.buyPrice(0, 2, 0, 0); + item.rare = 2; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/OpalStrike"); + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 6f; + item.useAmmo = 97; + } - public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, 0f); - return false; - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.Marble, 20); - recipe.AddIngredient(ItemID.Amber, 5); - recipe.AddIngredient(ItemID.Diamond, 3); - recipe.AddIngredient(ItemID.FlintlockPistol); - recipe.AddTile(TileID.Anvils); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.Marble, 20); + recipe.AddIngredient(ItemID.Amber, 5); + recipe.AddIngredient(ItemID.Diamond, 3); + recipe.AddIngredient(ItemID.FlintlockPistol); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } } diff --git a/Items/Weapons/Ranged/Photoviscerator.cs b/Items/Weapons/Ranged/Photoviscerator.cs index f01934d293..689b383ad4 100644 --- a/Items/Weapons/Ranged/Photoviscerator.cs +++ b/Items/Weapons/Ranged/Photoviscerator.cs @@ -11,6 +11,8 @@ namespace CalamityMod.Items.Weapons.Ranged public class Photoviscerator : ModItem { public const int CooldownTime = 60 * 7; // 7 second cooldown. + public const double AltFireDamageMult = 3.0; + public override void SetStaticDefaults() { DisplayName.SetDefault("Photoviscerator"); @@ -21,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 230; + item.damage = 370; item.ranged = true; item.width = 84; item.height = 30; @@ -68,14 +70,14 @@ namespace CalamityMod.Items.Weapons.Ranged { Vector2 velocity = new Vector2(speedX, speedY); position += velocity.ToRotation().ToRotationVector2() * 80f; - Projectile.NewProjectile(position, velocity.SafeNormalize(Vector2.Zero) * 17f, ModContent.ProjectileType(), damage * 3, knockBack, player.whoAmI); + Projectile.NewProjectile(position, velocity.SafeNormalize(Vector2.Zero) * 17f, ModContent.ProjectileType(), (int)(damage * AltFireDamageMult), knockBack, player.whoAmI); } else { for (int i = 0; i < 2; i++) { Vector2 velocity = new Vector2(speedX, speedY).RotatedByRandom(0.05f); - Projectile.NewProjectile(position, velocity, type, damage / 2, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, velocity, type, damage, knockBack, player.whoAmI, 0f, 0f); } if (Main.rand.NextBool(8)) { diff --git a/Items/Weapons/Rogue/Apoctolith.cs b/Items/Weapons/Rogue/Apoctolith.cs index 11507f71d8..aa832fd900 100644 --- a/Items/Weapons/Rogue/Apoctolith.cs +++ b/Items/Weapons/Rogue/Apoctolith.cs @@ -21,13 +21,13 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { - item.damage = 108; + item.damage = 120; item.shootSpeed = 15f; item.shoot = ModContent.ProjectileType(); item.width = 66; item.height = 64; - item.useTime = 25; - item.useAnimation = 25; + item.useTime = 24; + item.useAnimation = 24; item.useStyle = 1; item.knockBack = 10f; item.crit = 20; diff --git a/Items/Weapons/Rogue/Brimblade.cs b/Items/Weapons/Rogue/Brimblade.cs index 15ef83556b..07aa7437e5 100644 --- a/Items/Weapons/Rogue/Brimblade.cs +++ b/Items/Weapons/Rogue/Brimblade.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Rogue for (int i = -6; i <= 6; i += 4) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); - int dart = Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage / 2, knockBack * 0.5f, player.whoAmI, 0f, 0f); + int dart = Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage, knockBack * 0.5f, player.whoAmI, 0f, 0f); Main.projectile[dart].Calamity().forceRogue = true; } return false; diff --git a/Items/Weapons/Rogue/RogueWeapon.cs b/Items/Weapons/Rogue/RogueWeapon.cs index 286aefb989..e0bcb51f9a 100644 --- a/Items/Weapons/Rogue/RogueWeapon.cs +++ b/Items/Weapons/Rogue/RogueWeapon.cs @@ -52,6 +52,12 @@ namespace CalamityMod.Items.Weapons.Rogue return mod.GetPrefix(newPrefix).Type; } + public override bool NewPreReforge() + { + StealthStrikeDamage = 1f; + return true; + } + public sealed override void SetDefaults() { SafeSetDefaults(); diff --git a/Items/Weapons/Summon/BlackHawkRemote.cs b/Items/Weapons/Summon/BlackHawkRemote.cs index 48f63765ad..121e537e48 100644 --- a/Items/Weapons/Summon/BlackHawkRemote.cs +++ b/Items/Weapons/Summon/BlackHawkRemote.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 36; + item.damage = 32; item.mana = 10; item.width = 46; item.height = 28; diff --git a/Items/Weapons/Summon/GastricBelcherStaff.cs b/Items/Weapons/Summon/GastricBelcherStaff.cs index 4e5b46bd14..380aac1b23 100644 --- a/Items/Weapons/Summon/GastricBelcherStaff.cs +++ b/Items/Weapons/Summon/GastricBelcherStaff.cs @@ -19,12 +19,12 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 70; + item.damage = 60; item.mana = 10; item.width = 66; item.height = 70; item.useTime = item.useAnimation = 20; - item.useStyle = 1; + item.useStyle = ItemUseStyleID.SwingThrow; item.noMelee = true; item.knockBack = 1f; item.value = CalamityGlobalItem.Rarity7BuyPrice; diff --git a/Items/Weapons/Summon/RustyBeaconPrototype.cs b/Items/Weapons/Summon/RustyBeaconPrototype.cs index f5b3a70288..95760c4e02 100644 --- a/Items/Weapons/Summon/RustyBeaconPrototype.cs +++ b/Items/Weapons/Summon/RustyBeaconPrototype.cs @@ -44,8 +44,7 @@ namespace CalamityMod.Items.Weapons.Summon } public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 1); + ModRecipe recipe = new ModRecipe(mod);; recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddRecipeGroup("IronBar", 10); recipe.AddTile(TileID.Anvils); diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index da58f5e984..563cf4e0fd 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -545,11 +545,11 @@ namespace CalamityMod.NPCs } } - npc.lifeRegen -= projectileCount * 350; + npc.lifeRegen -= projectileCount * 250; - if (damage < projectileCount * 70) + if (damage < projectileCount * 50) { - damage = projectileCount * 70; + damage = projectileCount * 50; } } diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 172e08b78e..0addaf402a 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -164,7 +164,7 @@ namespace CalamityMod.NPCs DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 5, 1, 1); DropHelper.DropItemCondition(npc, ModContent.ItemType(), !Main.expertMode, 8, 1, 1); DropHelper.DropItemChance(npc, ModContent.ItemType(), !Main.hardMode, Main.hardMode ? 0.1f : 1f); // 100% chance on first kill, 10% chance afterwards - DropHelper.DropItemFromSetCondition(npc, !Main.expertMode, 5, ItemID.CorruptionKey, ItemID.CrimsonKey); + DropHelper.DropItemFromSetCondition(npc, !Main.expertMode, 0.2f, ItemID.CorruptionKey, ItemID.CrimsonKey); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !Main.hardMode); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !Main.hardMode); @@ -1614,16 +1614,18 @@ namespace CalamityMod.NPCs private void AcidRainProgression(NPC npc) { Dictionary possibleEnemies = AcidRainEvent.PossibleEnemiesPreHM; + if (CalamityWorld.downedAquaticScourge) possibleEnemies = AcidRainEvent.PossibleEnemiesAS; if (CalamityWorld.downedPolterghast) possibleEnemies = AcidRainEvent.PossibleEnemiesPolter; + if (possibleEnemies.Select(enemy => enemy.Key).Contains(npc.type) && CalamityWorld.rainingAcid) { CalamityWorld.acidRainPoints -= possibleEnemies[npc.type].InvasionContributionPoints; if (CalamityWorld.downedPolterghast) { - CalamityWorld.acidRainPoints = (int)MathHelper.Max(2, CalamityWorld.acidRainPoints); // Cap at 2. The last points are for Old Duke. + CalamityWorld.acidRainPoints = (int)MathHelper.Max(1, CalamityWorld.acidRainPoints); // Cap at 1. The last point is for Old Duke. } } Dictionary possibleMinibosses = CalamityWorld.downedPolterghast ? AcidRainEvent.PossibleMinibossesPolter : AcidRainEvent.PossibleMinibossesAS; @@ -1632,7 +1634,7 @@ namespace CalamityMod.NPCs CalamityWorld.acidRainPoints -= possibleMinibosses[npc.type].InvasionContributionPoints; if (CalamityWorld.downedPolterghast) { - CalamityWorld.acidRainPoints = (int)MathHelper.Max(2, CalamityWorld.acidRainPoints); // Cap at 2. The last points are for Old Duke. + CalamityWorld.acidRainPoints = (int)MathHelper.Max(1, CalamityWorld.acidRainPoints); // Cap at 1. The last point is for Old Duke. } } @@ -1645,6 +1647,7 @@ namespace CalamityMod.NPCs CalamityWorld.triedToSummonOldDuke = false; CalamityWorld.acidRainPoints = 0; } + CalamityWorld.timeSinceAcidRainKill = 0; AcidRainEvent.UpdateInvasion(); } #endregion diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 6b3323c9c9..a664be8030 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -2102,408 +2102,6 @@ namespace CalamityMod.Projectiles } } - public static void HealingProjectile(Projectile projectile, int healing, int playerToHeal, float homingVelocity, float N, bool autoHomes = true, int timeCheck = 120) - { - int target = playerToHeal; - Player player = Main.player[target]; - float homingSpeed = homingVelocity; - if (player.lifeMagnet) - homingSpeed *= 1.5f; - - Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y); - float xDist = player.Center.X - projPos.X; - float yDist = player.Center.Y - projPos.Y; - Vector2 playerVector = new Vector2(xDist, yDist); - float playerDist = playerVector.Length(); - if (playerDist < 50f && projectile.position.X < player.position.X + player.width && projectile.position.X + projectile.width > player.position.X && projectile.position.Y < player.position.Y + player.height && projectile.position.Y + projectile.height > player.position.Y) - { - if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) - { - int healAmt = healing; - player.HealEffect(healAmt, false); - player.statLife += healAmt; - if (player.statLife > player.statLifeMax2) - { - player.statLife = player.statLifeMax2; - } - NetMessage.SendData(MessageID.SpiritHeal, -1, -1, null, target, healAmt, 0f, 0f, 0, 0, 0); - } - projectile.Kill(); - } - if (autoHomes) - { - playerDist = homingSpeed / playerDist; - playerVector.X *= playerDist; - playerVector.Y *= playerDist; - projectile.velocity.X = (projectile.velocity.X * N + playerVector.X) / (N + 1f); - projectile.velocity.Y = (projectile.velocity.Y * N + playerVector.Y) / (N + 1f); - } - else if (player.lifeMagnet && projectile.timeLeft < timeCheck) - { - playerDist = homingVelocity / playerDist; - playerVector.X *= playerDist; - playerVector.Y *= playerDist; - projectile.velocity.X = (projectile.velocity.X * N + playerVector.X) / (N + 1f); - projectile.velocity.Y = (projectile.velocity.Y * N + playerVector.Y) / (N + 1f); - } - } - - public static void ChargingMinionAI(Projectile projectile, float range, float maxPlayerDist, float extraMaxPlayerDist, float safeDist, int initialUpdates, float chargeDelayTime, float goToSpeed, float goBackSpeed, float chargeCounterMax, float chargeSpeed, bool tileVision, bool ignoreTilesWhenCharging) - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - - //Anti sticky movement to prevent stacking - float antiStickMvt = 0.05f; - for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) - { - Projectile proj = Main.projectile[projIndex]; - bool typeCheck = proj.type == projectile.type; - if (projIndex != projectile.whoAmI && proj.active && proj.owner == projectile.owner && typeCheck && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X -= antiStickMvt; - } - else - { - projectile.velocity.X += antiStickMvt; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y -= antiStickMvt; - } - else - { - projectile.velocity.Y += antiStickMvt; - } - } - } - - //Breather time between charges as like a reset - bool chargeDelay = false; - if (projectile.ai[0] == 2f) - { - projectile.ai[1] += 1f; - projectile.extraUpdates = initialUpdates + (projectile.type == ModContent.ProjectileType() ? 2 : 1); - if (projectile.ai[1] > chargeDelayTime) - { - projectile.ai[1] = 1f; - projectile.ai[0] = 0f; - projectile.extraUpdates = initialUpdates; - projectile.numUpdates = 0; - projectile.netUpdate = true; - } - else - { - chargeDelay = true; - } - } - if (chargeDelay) - { - return; - } - - //Find a target - float maxDist = range; - Vector2 targetVec = projectile.position; - bool foundTarget = false; - Vector2 half = new Vector2(0.5f); - //Prioritize the targeted enemy if possible - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) - { - //Check the size of the target to make it easier to hit fat targets like Levi - Vector2 sizeCheck = npc.position + npc.Size * half; - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - //Some minions will ignore tiles when choosing a target like Ice Claspers, others will not - bool canHit = true; - if (!tileVision) - canHit = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); - if (!foundTarget && targetDist < maxDist && canHit) - { - maxDist = targetDist; - targetVec = sizeCheck; - foundTarget = true; - } - } - } - //If no npc is specifically targetted, check through the entire array - else - { - for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) - { - NPC npc = Main.npc[npcIndex]; - if (npc.CanBeChasedBy(projectile, false)) - { - Vector2 sizeCheck = npc.position + npc.Size * half; - float targetDist = Vector2.Distance(npc.Center, projectile.Center); - bool canHit = true; - if (!tileVision) - canHit = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); - if (!foundTarget && targetDist < maxDist && canHit) - { - maxDist = targetDist; - targetVec = sizeCheck; - foundTarget = true; - } - } - } - } - - //If the player is too far, return to the player. Range is increased while attacking something. - float distBeforeForcedReturn = maxPlayerDist; - if (foundTarget) - { - distBeforeForcedReturn = extraMaxPlayerDist; - } - if (Vector2.Distance(player.Center, projectile.Center) > distBeforeForcedReturn) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } - - //Go to the target if you found one - if (foundTarget && projectile.ai[0] == 0f) - { - //Some minions don't ignore tiles while charging like brittle stars - projectile.tileCollide = !ignoreTilesWhenCharging; - Vector2 targetSpot = targetVec - projectile.Center; - float targetDist = targetSpot.Length(); - targetSpot.Normalize(); - //Tries to get the minion in the sweet spot of 200 pixels away but the minion also charges so idk what good it does - if (targetDist > 200f) - { - float speed = goToSpeed; //8 - targetSpot *= speed; - projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; - } - else - { - float speed = -goBackSpeed; //-4 - targetSpot *= speed; - projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; //41 - } - } - - //Movement for idle or returning to the player - else - { - //Ignore tiles so they don't get stuck everywhere like Optic Staff - projectile.tileCollide = false; - - bool returningToPlayer = false; - if (!returningToPlayer) - { - returningToPlayer = projectile.ai[0] == 1f; - } - - //Player distance calculations - Vector2 playerVec = player.Center - projectile.Center + new Vector2(0f, -60f); - float playerDist = playerVec.Length(); - - //If the minion is actively returning, move faster - float playerHomeSpeed = 6f; - if (returningToPlayer) - { - playerHomeSpeed = 15f; - } - //Move somewhat faster if the player is kinda far~ish - if (playerDist > 200f && playerHomeSpeed < 8f) - { - playerHomeSpeed = 8f; - } - //Return to normal if close enough to the player - if (playerDist < safeDist && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - //Teleport to the player if abnormally far - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } - //If more than 70 pixels away, move toward the player - if (playerDist > 70f) - { - playerVec.Normalize(); - playerVec *= playerHomeSpeed; - projectile.velocity = (projectile.velocity * 40f + playerVec) / 41f; - } - //Minions never stay still - else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.15f; - projectile.velocity.Y = -0.05f; - } - } - - //Increment attack counter randomly - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += (float)Main.rand.Next(1, 4); - } - //If high enough, prepare to attack - if (projectile.ai[1] > chargeCounterMax) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - - //Charge at an enemy if not on cooldown - if (projectile.ai[0] == 0f) - { - if (projectile.ai[1] == 0f && foundTarget && maxDist < 500f) - { - projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner) - { - projectile.ai[0] = 2f; - Vector2 targetPos = targetVec - projectile.Center; - targetPos.Normalize(); - projectile.velocity = targetPos * chargeSpeed; //8 - projectile.netUpdate = true; - } - } - } - } - - public static void FloatingPetAI(Projectile projectile, bool faceRight, float tiltFloat, bool lightPet = false) - { - Player player = Main.player[projectile.owner]; - - //anti sticking movement as a failsafe - float SAImovement = 0.05f; - for (int index = 0; index < Main.projectile.Length; index++) - { - Projectile proj = Main.projectile[index]; - bool flag23 = Main.projPet[proj.type]; - if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X -= SAImovement; - } - else - { - projectile.velocity.X += SAImovement; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y -= SAImovement; - } - else - { - projectile.velocity.Y += SAImovement; - } - } - } - - float passiveMvtFloat = 0.5f; - projectile.tileCollide = false; - float range = 100f; - Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y); - float xDist = player.Center.X - projPos.X; - float yDist = player.Center.Y - projPos.Y; - yDist += Main.rand.NextFloat(-10, 20); - xDist += Main.rand.NextFloat(-10, 20); - //Light pets lead the player, normal pets trail the player - xDist += 60f * (lightPet ? (float)player.direction : -(float)player.direction); - yDist -= 60f; - Vector2 playerVector = new Vector2(xDist, yDist); - float playerDist = playerVector.Length(); - float returnSpeed = 18f; - - //If player is close enough, resume normal - if (playerDist < range && player.velocity.Y == 0f && - projectile.position.Y + projectile.height <= player.position.Y + player.height && - !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - if (projectile.velocity.Y < -6f) - { - projectile.velocity.Y = -6f; - } - } - - //Teleport to player if too far - if (playerDist > 2000f) - { - projectile.position.X = player.Center.X - projectile.width / 2; - projectile.position.Y = player.Center.Y - projectile.height / 2; - projectile.netUpdate = true; - } - - if (playerDist < 50f) - { - if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) - { - projectile.velocity *= 0.99f; - } - passiveMvtFloat = 0.01f; - } - else - { - if (playerDist < 100f) - { - passiveMvtFloat = 0.1f; - } - if (playerDist > 300f) - { - passiveMvtFloat = 1f; - } - playerDist = returnSpeed / playerDist; - playerVector.X *= playerDist; - playerVector.Y *= playerDist; - } - if (projectile.velocity.X < playerVector.X) - { - projectile.velocity.X += passiveMvtFloat; - if (passiveMvtFloat > 0.05f && projectile.velocity.X < 0f) - { - projectile.velocity.X += passiveMvtFloat; - } - } - if (projectile.velocity.X > playerVector.X) - { - projectile.velocity.X -= passiveMvtFloat; - if (passiveMvtFloat > 0.05f && projectile.velocity.X > 0f) - { - projectile.velocity.X -= passiveMvtFloat; - } - } - if (projectile.velocity.Y < playerVector.Y) - { - projectile.velocity.Y += passiveMvtFloat; - if (passiveMvtFloat > 0.05f && projectile.velocity.Y < 0f) - { - projectile.velocity.Y += passiveMvtFloat * 2f; - } - } - if (projectile.velocity.Y > playerVector.Y) - { - projectile.velocity.Y -= passiveMvtFloat; - if (passiveMvtFloat > 0.05f && projectile.velocity.Y > 0f) - { - projectile.velocity.Y -= passiveMvtFloat * 2f; - } - } - if (projectile.velocity.X >= 0.25f) - { - projectile.direction = faceRight ? 1 : -1; - } - else if (projectile.velocity.X < -0.25f) - { - projectile.direction = faceRight ? -1 : 1; - } - //Tilting and change directions - projectile.spriteDirection = projectile.direction; - projectile.rotation = projectile.velocity.X * tiltFloat; - } public static void ExpandHitboxBy(Projectile projectile, int width, int height) { projectile.position = projectile.Center; diff --git a/Projectiles/DraedonsArsenal/PulseRifleShot.cs b/Projectiles/DraedonsArsenal/PulseRifleShot.cs index f501dd16a5..d4db6eaaad 100644 --- a/Projectiles/DraedonsArsenal/PulseRifleShot.cs +++ b/Projectiles/DraedonsArsenal/PulseRifleShot.cs @@ -128,19 +128,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal if (!target.boss) { - if (target.HitSound != SoundID.NPCHit1 && target.HitSound != SoundID.NPCHit6 && target.HitSound != SoundID.NPCHit7 && - target.HitSound != SoundID.NPCHit8 && target.HitSound != SoundID.NPCHit9 && target.HitSound != SoundID.NPCHit12 && - target.HitSound != SoundID.NPCHit13 && target.HitSound != SoundID.NPCHit14 && target.HitSound != SoundID.NPCHit18 && - target.HitSound != SoundID.NPCHit19 && target.HitSound != SoundID.NPCHit20 && target.HitSound != SoundID.NPCHit21 && - target.HitSound != SoundID.NPCHit22 && target.HitSound != SoundID.NPCHit23 && target.HitSound != SoundID.NPCHit24 && - target.HitSound != SoundID.NPCHit25 && target.HitSound != SoundID.NPCHit26 && target.HitSound != SoundID.NPCHit27 && - target.HitSound != SoundID.NPCHit28 && target.HitSound != SoundID.NPCHit29 && target.HitSound != SoundID.NPCHit31 && - target.HitSound != SoundID.NPCHit32 && target.HitSound != SoundID.NPCHit33 && target.HitSound != SoundID.NPCHit35 && - target.HitSound != SoundID.NPCHit37 && target.HitSound != SoundID.NPCHit38 && target.HitSound != SoundID.NPCHit40 && - target.HitSound != SoundID.NPCHit43 && target.HitSound != SoundID.NPCHit44 && target.HitSound != SoundID.NPCHit45 && - target.HitSound != SoundID.NPCHit46 && target.HitSound != SoundID.NPCHit47 && target.HitSound != SoundID.NPCHit48 && - target.HitSound != SoundID.NPCHit50 && target.HitSound != SoundID.NPCHit51 && target.HitSound != SoundID.NPCHit55 && - target.HitSound != SoundID.NPCHit56 && target.HitSound != SoundID.NPCHit57) + if (target.Inorganic()) { damage += target.lifeMax / 250; } diff --git a/Projectiles/DraedonsArsenal/TeslaCannonShot.cs b/Projectiles/DraedonsArsenal/TeslaCannonShot.cs index 01ac483735..e2b8ab0df7 100644 --- a/Projectiles/DraedonsArsenal/TeslaCannonShot.cs +++ b/Projectiles/DraedonsArsenal/TeslaCannonShot.cs @@ -143,11 +143,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { if (projectile.ai[1] >= 0f) { - if (target.HitSound != SoundID.NPCHit4 && target.HitSound != SoundID.NPCHit41 && target.HitSound != SoundID.NPCHit2 && - target.HitSound != SoundID.NPCHit5 && target.HitSound != SoundID.NPCHit11 && target.HitSound != SoundID.NPCHit30 && - target.HitSound != SoundID.NPCHit34 && target.HitSound != SoundID.NPCHit36 && target.HitSound != SoundID.NPCHit42 && - target.HitSound != SoundID.NPCHit49 && target.HitSound != SoundID.NPCHit52 && target.HitSound != SoundID.NPCHit53 && - target.HitSound != SoundID.NPCHit54 && target.HitSound != null) + if (target.Organic()) { target.velocity.X = 0f; target.velocity.Y = 0f; diff --git a/Projectiles/Healing/AtaxiaHealOrb.cs b/Projectiles/Healing/AtaxiaHealOrb.cs index 1e2d73cc27..f886f3a334 100644 --- a/Projectiles/Healing/AtaxiaHealOrb.cs +++ b/Projectiles/Healing/AtaxiaHealOrb.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f); int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 100, default, 2f); Dust dust = Main.dust[dusty]; dust.noGravity = true; diff --git a/Projectiles/Healing/AuricOrb.cs b/Projectiles/Healing/AuricOrb.cs index 9fc7f6454e..60995c3d47 100644 --- a/Projectiles/Healing/AuricOrb.cs +++ b/Projectiles/Healing/AuricOrb.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Healing } } - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f); return; } diff --git a/Projectiles/Healing/BurntSiennaProj.cs b/Projectiles/Healing/BurntSiennaProj.cs index 13e5238014..c6c3346e9d 100644 --- a/Projectiles/Healing/BurntSiennaProj.cs +++ b/Projectiles/Healing/BurntSiennaProj.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Healing projectile.velocity.X *= 0.95f; projectile.velocity.Y *= 0.95f; - CalamityGlobalProjectile.HealingProjectile(projectile, 3, (int)projectile.ai[0], 6f, 15f, false); + projectile.HealingProjectile(3, (int)projectile.ai[0], 6f, 15f, false); int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, default, 1f); Dust dust = Main.dust[dusty]; dust.noGravity = true; diff --git a/Projectiles/Healing/CactusHealOrb.cs b/Projectiles/Healing/CactusHealOrb.cs index 30d4d0449d..654c25a857 100644 --- a/Projectiles/Healing/CactusHealOrb.cs +++ b/Projectiles/Healing/CactusHealOrb.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Healing { projectile.velocity.Y *= 0.98f; - CalamityGlobalProjectile.HealingProjectile(projectile, 25, projectile.owner, 12f, 15f); + projectile.HealingProjectile(25, projectile.owner, 12f, 15f); int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(0, 200, 0), 1.5f); Dust dust = Main.dust[dusty]; dust.noGravity = true; diff --git a/Projectiles/Healing/EarthHealOrb.cs b/Projectiles/Healing/EarthHealOrb.cs index 701590c6cc..6c936348f5 100644 --- a/Projectiles/Healing/EarthHealOrb.cs +++ b/Projectiles/Healing/EarthHealOrb.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 8f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 8f, 15f); int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 74, 0f, 0f, 100, default, 1f); Dust dust = Main.dust[dusty]; dust.noGravity = true; diff --git a/Projectiles/Healing/EssenceFlame.cs b/Projectiles/Healing/EssenceFlame.cs index f497e31bbd..2080699aaf 100644 --- a/Projectiles/Healing/EssenceFlame.cs +++ b/Projectiles/Healing/EssenceFlame.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.Healing projectile.frame = 0; } - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 3.5f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 3.5f, 15f); return; } diff --git a/Projectiles/Healing/Exoheal.cs b/Projectiles/Healing/Exoheal.cs index 745d106fe4..bcbfbf33d0 100644 --- a/Projectiles/Healing/Exoheal.cs +++ b/Projectiles/Healing/Exoheal.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 8f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 8f, 15f); int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); Dust dust = Main.dust[dusty]; dust.noGravity = true; diff --git a/Projectiles/Healing/FungalHeal.cs b/Projectiles/Healing/FungalHeal.cs index 35edf8c598..dbe1764206 100644 --- a/Projectiles/Healing/FungalHeal.cs +++ b/Projectiles/Healing/FungalHeal.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Healing projectile.localAI[0] += 1f; } - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 5f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 5f, 15f); float num494 = projectile.velocity.X * 0.334f; float num495 = -(projectile.velocity.Y * 0.334f); int num496 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 56, 0f, 0f, 100, default, 0.5f); diff --git a/Projectiles/Healing/GodSlayerHealOrb.cs b/Projectiles/Healing/GodSlayerHealOrb.cs index a1f66abfb7..bb6d057f40 100644 --- a/Projectiles/Healing/GodSlayerHealOrb.cs +++ b/Projectiles/Healing/GodSlayerHealOrb.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6.5f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 6.5f, 15f); int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 173, 0f, 0f, 100, default, 2f); Dust dust = Main.dust[dusty]; dust.noGravity = true; diff --git a/Projectiles/Healing/ManaOverloaderHealOrb.cs b/Projectiles/Healing/ManaOverloaderHealOrb.cs index d470be1db8..bfd57807c9 100644 --- a/Projectiles/Healing/ManaOverloaderHealOrb.cs +++ b/Projectiles/Healing/ManaOverloaderHealOrb.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 3f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 3f, 15f); int dusty = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 175, 0f, 0f, 100, default, 1.3f); Dust dust = Main.dust[dusty]; dust.noGravity = true; diff --git a/Projectiles/Healing/PhoenixHeal.cs b/Projectiles/Healing/PhoenixHeal.cs index b53ddd51e7..0434f84892 100644 --- a/Projectiles/Healing/PhoenixHeal.cs +++ b/Projectiles/Healing/PhoenixHeal.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Healing { projectile.velocity.X *= 0.95f; projectile.velocity.Y *= 0.95f; - CalamityGlobalProjectile.HealingProjectile(projectile, 10, (int)projectile.ai[0], 6f, 15f, false, 360); + projectile.HealingProjectile(10, (int)projectile.ai[0], 6f, 15f, false, 360); float num498 = projectile.velocity.X * 0.2f; float num499 = -(projectile.velocity.Y * 0.2f); int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); diff --git a/Projectiles/Healing/RainHeal.cs b/Projectiles/Healing/RainHeal.cs index 31a8effd9a..329c8fdb07 100644 --- a/Projectiles/Healing/RainHeal.cs +++ b/Projectiles/Healing/RainHeal.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Healing { projectile.velocity.X *= 0.985f; projectile.velocity.Y *= 0.985f; - CalamityGlobalProjectile.HealingProjectile(projectile, 8, projectile.owner, 12f, 15f, false); + projectile.HealingProjectile(8, projectile.owner, 12f, 15f, false); float num498 = projectile.velocity.X * 0.2f; float num499 = -(projectile.velocity.Y * 0.2f); diff --git a/Projectiles/Healing/RoyalHeal.cs b/Projectiles/Healing/RoyalHeal.cs index 39eadfa9e7..7d0b933b52 100644 --- a/Projectiles/Healing/RoyalHeal.cs +++ b/Projectiles/Healing/RoyalHeal.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f); for (int num493 = 0; num493 < 3; num493++) { float num494 = projectile.velocity.X * 0.334f * (float)num493; diff --git a/Projectiles/Healing/ShinobiHealOrb.cs b/Projectiles/Healing/ShinobiHealOrb.cs index b6a6ae38ee..f1a9380519 100644 --- a/Projectiles/Healing/ShinobiHealOrb.cs +++ b/Projectiles/Healing/ShinobiHealOrb.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], projectile.owner, 6f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], projectile.owner, 6f, 15f); for (int num468 = 0; num468 < 3; num468++) { diff --git a/Projectiles/Healing/SilvaOrb.cs b/Projectiles/Healing/SilvaOrb.cs index 0c0edd5ea3..9bece10e72 100644 --- a/Projectiles/Healing/SilvaOrb.cs +++ b/Projectiles/Healing/SilvaOrb.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Healing } } - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 6f, 15f); return; } diff --git a/Projectiles/Healing/TerracottaProj.cs b/Projectiles/Healing/TerracottaProj.cs index 5f8df0b108..e9fdc8ca58 100644 --- a/Projectiles/Healing/TerracottaProj.cs +++ b/Projectiles/Healing/TerracottaProj.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Healing projectile.velocity.X *= 0.95f; projectile.velocity.Y *= 0.95f; - CalamityGlobalProjectile.HealingProjectile(projectile, 9, (int)projectile.ai[0], 8f, 15f, false, 300); + projectile.HealingProjectile(9, (int)projectile.ai[0], 8f, 15f, false, 300); float num498 = projectile.velocity.X * 0.2f; float num499 = -(projectile.velocity.Y * 0.2f); int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, default, 1f); diff --git a/Projectiles/Healing/TransfusionTrail.cs b/Projectiles/Healing/TransfusionTrail.cs index e085edeb0b..cf1d9d6fbc 100644 --- a/Projectiles/Healing/TransfusionTrail.cs +++ b/Projectiles/Healing/TransfusionTrail.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 6.5f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 6.5f, 15f); float num494 = projectile.velocity.X * 0.334f; float num495 = -(projectile.velocity.Y * 0.334f); int num496 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 183, 0f, 0f, 100, default, 0.7f); diff --git a/Projectiles/Healing/XerocHealOrb.cs b/Projectiles/Healing/XerocHealOrb.cs index f216c96e4a..c5d09d22e5 100644 --- a/Projectiles/Healing/XerocHealOrb.cs +++ b/Projectiles/Healing/XerocHealOrb.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - CalamityGlobalProjectile.HealingProjectile(projectile, (int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f); + projectile.HealingProjectile((int)projectile.ai[1], (int)projectile.ai[0], 5.5f, 15f); float num498 = projectile.velocity.X * 0.2f; float num499 = -(projectile.velocity.Y * 0.2f); int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 58, 0f, 0f, 100, default, 2f); diff --git a/Projectiles/Magic/AtlantisSpear.cs b/Projectiles/Magic/AtlantisSpear.cs index 2c753aa87b..8702e8bb35 100644 --- a/Projectiles/Magic/AtlantisSpear.cs +++ b/Projectiles/Magic/AtlantisSpear.cs @@ -3,7 +3,6 @@ using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ID; namespace CalamityMod.Projectiles.Magic { diff --git a/Projectiles/Magic/PlagueFang.cs b/Projectiles/Magic/PlagueFang.cs index 8368ed6e6a..231dd0d669 100644 --- a/Projectiles/Magic/PlagueFang.cs +++ b/Projectiles/Magic/PlagueFang.cs @@ -23,6 +23,8 @@ namespace CalamityMod.Projectiles.Magic projectile.alpha = 255; projectile.penetrate = 9; projectile.timeLeft = 300; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 5; } public override void AI() @@ -80,7 +82,6 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 300); - target.immune[projectile.owner] = 2; } } } diff --git a/Projectiles/Magic/VividBeam.cs b/Projectiles/Magic/VividBeam.cs index 1bba3fbf3a..834975c128 100644 --- a/Projectiles/Magic/VividBeam.cs +++ b/Projectiles/Magic/VividBeam.cs @@ -113,28 +113,27 @@ namespace CalamityMod.Projectiles.Magic { if (projectile.ai[1] == 0f) { - float x = projectile.position.X + (float)Main.rand.Next(-400, 400); - float y = projectile.position.Y - (float)Main.rand.Next(500, 800); - Vector2 vector = new Vector2(x, y); - float num15 = projectile.position.X + (float)(projectile.width / 2) - vector.X; - float num16 = projectile.position.Y + (float)(projectile.height / 2) - vector.Y; - num15 += (float)Main.rand.Next(-100, 101); - float num17 = 6f; - float num18 = (float)Math.Sqrt((double)(num15 * num15 + num16 * num16)); - num18 = num17 / num18; - num15 *= num18; - num16 *= num18; - int num19 = Projectile.NewProjectile(x, y, num15, num16, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + float xStart = projectile.position.X + (float)Main.rand.Next(-400, 400); + float yStart = projectile.position.Y - (float)Main.rand.Next(500, 800); + Vector2 startPos = new Vector2(xStart, yStart); + Vector2 velocity = projectile.Center - startPos; + velocity.X += (float)Main.rand.Next(-100, 101); + float speed = 6f; + float targetDist = velocity.Length(); + targetDist = speed / targetDist; + velocity.X *= targetDist; + velocity.Y *= targetDist; + int num19 = Projectile.NewProjectile(startPos, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.7f), projectile.knockBack, projectile.owner, 0f, 0f); Main.projectile[num19].ai[1] = projectile.position.Y; } if (projectile.ai[1] == 1f) { - int boom = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)((double)projectile.damage * 2f), projectile.knockBack, projectile.owner, 0f, 0f); + int boom = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 2f), projectile.knockBack, projectile.owner, 0f, 0f); Main.projectile[boom].Calamity().forceMagic = true; } if (projectile.ai[1] == 2f) { - float spread = 30f * 0.0174f; + float spread = 30f * 0.01f * MathHelper.PiOver2; double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; @@ -143,8 +142,8 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 4; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)((double)projectile.damage * 0.2f), projectile.knockBack, projectile.owner, 0f, 0f); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)((double)projectile.damage * 0.2f), projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Melee/CosmicShivBall.cs b/Projectiles/Melee/CosmicShivBall.cs index f05f4469b8..30dee538fd 100644 --- a/Projectiles/Melee/CosmicShivBall.cs +++ b/Projectiles/Melee/CosmicShivBall.cs @@ -78,15 +78,15 @@ namespace CalamityMod.Projectiles.Melee int directionSign = Main.rand.NextBool(2).ToDirectionInt(); Vector2 spawnPos = new Vector2(target.Center.X + directionSign * 650, projectile.Center.Y + Main.rand.Next(-500, 501)); Vector2 velocity = Vector2.Normalize(target.Center - spawnPos) * 30f; - Projectile.NewProjectile(spawnPos.X, spawnPos.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), projectile.damage, 1.4f, projectile.owner); + Projectile.NewProjectile(spawnPos.X, spawnPos.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), projectile.damage, projectile.knockBack * 0.1f, projectile.owner); } - int starMax = Main.rand.Next(4, 11); // 4 to 10 stars + int starMax = Main.rand.Next(6, 11); // 6 to 10 stars for (int i = -starMax / 2; i < starMax / 2; i++) { int ySpawnAdditive = Main.rand.Next(-40, 41); Vector2 toSpawn = target.Center - new Vector2(0f, 800f + ySpawnAdditive).RotatedBy(MathHelper.ToRadians(i * 11f / starMax)); Vector2 toTarget = Vector2.Normalize(target.Center - toSpawn) * 35f; - Projectile.NewProjectile(toSpawn, toTarget, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + Projectile.NewProjectile(toSpawn, toTarget, ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner); } target.AddBuff(ModContent.BuffType(), 360); target.AddBuff(ModContent.BuffType(), 360); diff --git a/Projectiles/Melee/ProfanedSwordProj.cs b/Projectiles/Melee/ProfanedSwordProj.cs index 3a4814ab98..dbaef5da37 100644 --- a/Projectiles/Melee/ProfanedSwordProj.cs +++ b/Projectiles/Melee/ProfanedSwordProj.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Melee { if (explosionCount < 3) { - Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), knockback, projectile.owner); + Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), knockback, projectile.owner); explosionCount++; } } diff --git a/Projectiles/Pets/Akato.cs b/Projectiles/Pets/Akato.cs index 226e7e542a..6aa169688e 100644 --- a/Projectiles/Pets/Akato.cs +++ b/Projectiles/Pets/Akato.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Pets { projectile.timeLeft = 2; } - CalamityGlobalProjectile.FloatingPetAI(projectile, true, 0.02f); + projectile.FloatingPetAI(true, 0.02f); projectile.frameCounter++; if (projectile.frameCounter > 6) { diff --git a/Projectiles/Pets/BabyGhostBell.cs b/Projectiles/Pets/BabyGhostBell.cs index 3159bd7951..d85eb5a67f 100644 --- a/Projectiles/Pets/BabyGhostBell.cs +++ b/Projectiles/Pets/BabyGhostBell.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Pets { Lighting.AddLight(projectile.Center, 0.1f, 0.3f, 0.5f); } - CalamityGlobalProjectile.FloatingPetAI(projectile, false, 0.05f, true); + projectile.FloatingPetAI(false, 0.05f, true); projectile.frameCounter++; if (projectile.frameCounter > 6) { diff --git a/Projectiles/Pets/LeviPet.cs b/Projectiles/Pets/LeviPet.cs index a883f0c6b3..8a0f51d3f5 100644 --- a/Projectiles/Pets/LeviPet.cs +++ b/Projectiles/Pets/LeviPet.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Pets { projectile.timeLeft = 2; } - CalamityGlobalProjectile.FloatingPetAI(projectile, false, 0.05f); + projectile.FloatingPetAI(false, 0.05f); projectile.frameCounter++; if (projectile.frameCounter > 6) { diff --git a/Projectiles/Pets/PerforaMini.cs b/Projectiles/Pets/PerforaMini.cs index ae31133bdb..41a0dabd19 100644 --- a/Projectiles/Pets/PerforaMini.cs +++ b/Projectiles/Pets/PerforaMini.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Pets projectile.timeLeft = 2; } - CalamityGlobalProjectile.FloatingPetAI(projectile, true, 0.1f); + projectile.FloatingPetAI(true, 0.1f); //Dust if (Main.rand.NextBool(50)) diff --git a/Projectiles/Pets/PlaguebringerBab.cs b/Projectiles/Pets/PlaguebringerBab.cs index 74cfaa9c89..09f00c3a14 100644 --- a/Projectiles/Pets/PlaguebringerBab.cs +++ b/Projectiles/Pets/PlaguebringerBab.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Pets { projectile.timeLeft = 2; } - CalamityGlobalProjectile.FloatingPetAI(projectile, false, 0.05f); + projectile.FloatingPetAI(false, 0.05f); projectile.frameCounter++; if (projectile.frameCounter > 6) { diff --git a/Projectiles/Pets/RotomPet.cs b/Projectiles/Pets/RotomPet.cs index 543ca7435f..241890e028 100644 --- a/Projectiles/Pets/RotomPet.cs +++ b/Projectiles/Pets/RotomPet.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Pets dust += 1f; } - CalamityGlobalProjectile.FloatingPetAI(projectile, true, 0.05f); + projectile.FloatingPetAI(true, 0.05f); projectile.frameCounter++; if (projectile.frameCounter > 6) diff --git a/Projectiles/Pets/SCalPet.cs b/Projectiles/Pets/SCalPet.cs index 8fdbf5f476..20b29b0c08 100644 --- a/Projectiles/Pets/SCalPet.cs +++ b/Projectiles/Pets/SCalPet.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Pets { projectile.timeLeft = 2; } - CalamityGlobalProjectile.FloatingPetAI(projectile, false, 0.05f); + projectile.FloatingPetAI(false, 0.05f); projectile.frameCounter++; if (projectile.frameCounter > 6) { diff --git a/Projectiles/Pets/ThirdSage.cs b/Projectiles/Pets/ThirdSage.cs index 1f0df37832..af9b8a81ec 100644 --- a/Projectiles/Pets/ThirdSage.cs +++ b/Projectiles/Pets/ThirdSage.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Pets { projectile.timeLeft = 2; } - CalamityGlobalProjectile.FloatingPetAI(projectile, true, 0.1f); + projectile.FloatingPetAI(true, 0.1f); //Animation projectile.frameCounter++; if (projectile.frameCounter > 6) diff --git a/Projectiles/Ranged/AMRShot.cs b/Projectiles/Ranged/AMRShot.cs index 04af628f94..08b817254f 100644 --- a/Projectiles/Ranged/AMRShot.cs +++ b/Projectiles/Ranged/AMRShot.cs @@ -4,7 +4,6 @@ using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using Terraria.ID; namespace CalamityMod.Projectiles.Ranged { diff --git a/Projectiles/Ranged/ButcherGun.cs b/Projectiles/Ranged/ButcherGun.cs index cacf434e0c..47036152cd 100644 --- a/Projectiles/Ranged/ButcherGun.cs +++ b/Projectiles/Ranged/ButcherGun.cs @@ -30,40 +30,42 @@ namespace CalamityMod.Projectiles.Ranged projectile.ai[0] += 1f; int incrementAmt = 0; float spreadMult = 0.15f; - if (projectile.ai[0] >= 90f) + if (projectile.ai[0] >= 80f) { incrementAmt++; spreadMult = 0.13f; } - if (projectile.ai[0] >= 180f) + if (projectile.ai[0] >= 160f) { incrementAmt++; spreadMult = 0.11f; } - if (projectile.ai[0] >= 270f) + if (projectile.ai[0] >= 240f) { incrementAmt++; spreadMult = 0.09f; } - if (projectile.ai[0] >= 360f) + if (projectile.ai[0] >= 320f) { incrementAmt++; spreadMult = 0.07f; } - if (projectile.ai[0] >= 450f) + if (projectile.ai[0] >= 400f) { + incrementAmt++; spreadMult = 0.05f; } - if (projectile.ai[0] >= 540f) + if (projectile.ai[0] >= 480f) { incrementAmt++; spreadMult = 0.04f; } - if (projectile.ai[0] >= 630f) + if (projectile.ai[0] >= 560f) { + incrementAmt++; spreadMult = 0.03f; } - if (projectile.ai[0] >= 720f) //8 + if (projectile.ai[0] >= 640f) //8 { incrementAmt++; spreadMult = 0.02f; diff --git a/Projectiles/Ranged/ExoLight.cs b/Projectiles/Ranged/ExoLight.cs index b86913a0af..a87ba62638 100644 --- a/Projectiles/Ranged/ExoLight.cs +++ b/Projectiles/Ranged/ExoLight.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 5; + projectile.localNPCHitCooldown = 8; projectile.timeLeft = 180; } public override void AI() diff --git a/Projectiles/Ranged/ImpactRound.cs b/Projectiles/Ranged/ImpactRound.cs index 72e536c9d0..c471d98944 100644 --- a/Projectiles/Ranged/ImpactRound.cs +++ b/Projectiles/Ranged/ImpactRound.cs @@ -51,19 +51,7 @@ namespace CalamityMod.Projectiles.Ranged { damageMult += 0.25; } - if (target.HitSound != SoundID.NPCHit1 && target.HitSound != SoundID.NPCHit6 && target.HitSound != SoundID.NPCHit7 && - target.HitSound != SoundID.NPCHit8 && target.HitSound != SoundID.NPCHit9 && target.HitSound != SoundID.NPCHit12 && - target.HitSound != SoundID.NPCHit13 && target.HitSound != SoundID.NPCHit14 && target.HitSound != SoundID.NPCHit18 && - target.HitSound != SoundID.NPCHit19 && target.HitSound != SoundID.NPCHit20 && target.HitSound != SoundID.NPCHit21 && - target.HitSound != SoundID.NPCHit22 && target.HitSound != SoundID.NPCHit23 && target.HitSound != SoundID.NPCHit24 && - target.HitSound != SoundID.NPCHit25 && target.HitSound != SoundID.NPCHit26 && target.HitSound != SoundID.NPCHit27 && - target.HitSound != SoundID.NPCHit28 && target.HitSound != SoundID.NPCHit29 && target.HitSound != SoundID.NPCHit31 && - target.HitSound != SoundID.NPCHit32 && target.HitSound != SoundID.NPCHit33 && target.HitSound != SoundID.NPCHit35 && - target.HitSound != SoundID.NPCHit37 && target.HitSound != SoundID.NPCHit38 && target.HitSound != SoundID.NPCHit40 && - target.HitSound != SoundID.NPCHit43 && target.HitSound != SoundID.NPCHit44 && target.HitSound != SoundID.NPCHit45 && - target.HitSound != SoundID.NPCHit46 && target.HitSound != SoundID.NPCHit47 && target.HitSound != SoundID.NPCHit48 && - target.HitSound != SoundID.NPCHit50 && target.HitSound != SoundID.NPCHit51 && target.HitSound != SoundID.NPCHit55 && - target.HitSound != SoundID.NPCHit56 && target.HitSound != SoundID.NPCHit57) + if (target.Inorganic()) { damageMult += 0.1; } diff --git a/Projectiles/Rogue/FinalDawnFireSlash.cs b/Projectiles/Rogue/FinalDawnFireSlash.cs index b3930b6fa6..18e059abb4 100644 --- a/Projectiles/Rogue/FinalDawnFireSlash.cs +++ b/Projectiles/Rogue/FinalDawnFireSlash.cs @@ -33,6 +33,9 @@ namespace CalamityMod.Projectiles.Rogue { Player player = Main.player[projectile.owner]; + if (player.dead || player is null || Main.myPlayer != projectile.owner) + projectile.Kill(); + player.direction = projectile.direction; player.heldProj = projectile.whoAmI; diff --git a/Projectiles/Rogue/FinalDawnHorizontalSlash.cs b/Projectiles/Rogue/FinalDawnHorizontalSlash.cs index d7d6474030..5ed9d58eea 100644 --- a/Projectiles/Rogue/FinalDawnHorizontalSlash.cs +++ b/Projectiles/Rogue/FinalDawnHorizontalSlash.cs @@ -29,6 +29,10 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { Player player = Main.player[projectile.owner]; + + if (player.dead || player is null || Main.myPlayer != projectile.owner) + projectile.Kill(); + projectile.Center = player.Center; player.heldProj = projectile.whoAmI; projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt(); diff --git a/Projectiles/Rogue/FinalDawnProjectile.cs b/Projectiles/Rogue/FinalDawnProjectile.cs index c2f298dd27..a7e799af8d 100644 --- a/Projectiles/Rogue/FinalDawnProjectile.cs +++ b/Projectiles/Rogue/FinalDawnProjectile.cs @@ -30,6 +30,9 @@ namespace CalamityMod.Projectiles.Rogue { Player player = Main.player[projectile.owner]; + if (player.dead || player is null || Main.myPlayer != projectile.owner) + projectile.Kill(); + if (Main.myPlayer == player.whoAmI) { projectile.velocity = Main.MouseWorld - player.Center; diff --git a/Projectiles/Rogue/FinalDawnThrow.cs b/Projectiles/Rogue/FinalDawnThrow.cs index 04c7a8ceae..9151e544a7 100644 --- a/Projectiles/Rogue/FinalDawnThrow.cs +++ b/Projectiles/Rogue/FinalDawnThrow.cs @@ -33,12 +33,16 @@ namespace CalamityMod.Projectiles.Rogue } public override void AI() { + Player player = Main.player[projectile.owner]; + + if (player.dead || player is null || Main.myPlayer != projectile.owner) + projectile.Kill(); + if (projectile.localAI[0] == 0) { Main.PlaySound(SoundID.Item71, (int)projectile.position.X, (int)projectile.position.Y); projectile.localAI[0] = 1; } - Player player = Main.player[projectile.owner]; projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation += 0.25f * projectile.direction; diff --git a/Projectiles/Rogue/FinalDawnThrow2.cs b/Projectiles/Rogue/FinalDawnThrow2.cs index a247f73d2e..80aa357634 100644 --- a/Projectiles/Rogue/FinalDawnThrow2.cs +++ b/Projectiles/Rogue/FinalDawnThrow2.cs @@ -53,12 +53,16 @@ namespace CalamityMod.Projectiles.Rogue } public override void AI() { + Player player = Main.player[projectile.owner]; + + if (player.dead || player is null || Main.myPlayer != projectile.owner) + projectile.Kill(); + if (projectile.localAI[0] == 0) { Main.PlaySound(SoundID.Item71, projectile.position); projectile.localAI[0] = 1; } - Player player = Main.player[projectile.owner]; projectile.spriteDirection = projectile.velocity.X > 0 ? 1 : -1; projectile.rotation += 0.25f * projectile.direction; diff --git a/Projectiles/Rogue/FrostShardFriendly.cs b/Projectiles/Rogue/FrostShardFriendly.cs index fd43227505..c48e26e7bd 100644 --- a/Projectiles/Rogue/FrostShardFriendly.cs +++ b/Projectiles/Rogue/FrostShardFriendly.cs @@ -67,7 +67,8 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.Item27, projectile.position); + if (projectile.ai[0] != 1f || Main.rand.NextBool(20)) + Main.PlaySound(SoundID.Item27, projectile.position); for (int index1 = 0; index1 < 3; ++index1) { int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 76); diff --git a/Projectiles/Summon/ApexShark.cs b/Projectiles/Summon/ApexShark.cs index 21a06feb9d..3a062aa18b 100644 --- a/Projectiles/Summon/ApexShark.cs +++ b/Projectiles/Summon/ApexShark.cs @@ -94,31 +94,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && - flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } + projectile.MinionAntiClump(); bool flag24 = false; if (projectile.ai[0] == 2f) { diff --git a/Projectiles/Summon/AquaticStarMinion.cs b/Projectiles/Summon/AquaticStarMinion.cs index 10eed0167d..0fd44c83fc 100644 --- a/Projectiles/Summon/AquaticStarMinion.cs +++ b/Projectiles/Summon/AquaticStarMinion.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Summon } projectile.rotation += projectile.velocity.X * 0.04f; - CalamityGlobalProjectile.ChargingMinionAI(projectile, 600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, false); + projectile.ChargingMinionAI(600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 9.5f, false, false); } public override bool OnTileCollide(Vector2 oldVelocity) => false; diff --git a/Projectiles/Summon/AureusBomber.cs b/Projectiles/Summon/AureusBomber.cs index 13463aec45..a4be169099 100644 --- a/Projectiles/Summon/AureusBomber.cs +++ b/Projectiles/Summon/AureusBomber.cs @@ -70,32 +70,7 @@ namespace CalamityMod.Projectiles.Summon } //anti sticking movement - float SAImovement = 0.05f; - float width = (float) projectile.width; - for (int indexNPC = 0; indexNPC < Main.projectile.Length; indexNPC++) - { - Projectile proj = Main.projectile[indexNPC]; - bool myType = proj.type == ModContent.ProjectileType(); - if (indexNPC != projectile.whoAmI && proj.active && proj.owner == projectile.owner && myType && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X -= SAImovement; - } - else - { - projectile.velocity.X += SAImovement; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y -= SAImovement; - } - else - { - projectile.velocity.Y += SAImovement; - } - } - } + projectile.MinionAntiClump(); //get in a line Vector2 idlePosition = player.Center; diff --git a/Projectiles/Summon/BabyBloodCrawler.cs b/Projectiles/Summon/BabyBloodCrawler.cs index f5b91bd9d2..f0d3a1b2d4 100644 --- a/Projectiles/Summon/BabyBloodCrawler.cs +++ b/Projectiles/Summon/BabyBloodCrawler.cs @@ -51,7 +51,10 @@ namespace CalamityMod.Projectiles.Summon for (int j = 0; j < Main.maxProjectiles; j++) { Projectile proj = Main.projectile[j]; - if (proj.active && proj.owner == projectile.owner && proj.type == ModContent.ProjectileType() && proj.Calamity().lineColor == 0) + // Short circuits to make the loop as fast as possible + if (!proj.active || proj.owner != projectile.owner || !proj.minion || proj.Calamity().lineColor != 0) + continue; + if (proj.type == projectile.type) { spiderCount += (int)proj.minionSlots; proj.Calamity().lineColor = 1; diff --git a/Projectiles/Summon/BelladonnaSpirit.cs b/Projectiles/Summon/BelladonnaSpirit.cs index 298940e9d5..fcc0f64794 100644 --- a/Projectiles/Summon/BelladonnaSpirit.cs +++ b/Projectiles/Summon/BelladonnaSpirit.cs @@ -142,32 +142,7 @@ namespace CalamityMod.Projectiles.Summon } projectile.velocity.Y = (targetPosition.Y - projectile.Center.Y + potentialTarget.spriteDirection * 75f) / 90f; } - float SAImovement = 0.05f; - for (int index = 0; index < Main.projectile.Length; index++) - { - Projectile proj = Main.projectile[index]; - if (index != projectile.whoAmI && - proj.active && proj.owner == projectile.owner && - proj.type == projectile.type && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X -= SAImovement; - } - else - { - projectile.velocity.X += SAImovement; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y -= SAImovement; - } - else - { - projectile.velocity.Y += SAImovement; - } - } - } + projectile.MinionAntiClump(); } } } diff --git a/Projectiles/Summon/BlackHawkGlow.png b/Projectiles/Summon/BlackHawkGlow.png new file mode 100644 index 0000000000..24479cb839 Binary files /dev/null and b/Projectiles/Summon/BlackHawkGlow.png differ diff --git a/Projectiles/Summon/BlackHawkSummon.cs b/Projectiles/Summon/BlackHawkSummon.cs index 6161961044..c0974c50fd 100644 --- a/Projectiles/Summon/BlackHawkSummon.cs +++ b/Projectiles/Summon/BlackHawkSummon.cs @@ -1,6 +1,8 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; +using CalamityMod.Projectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ID; @@ -9,8 +11,6 @@ namespace CalamityMod.Projectiles.Summon { public class BlackHawkSummon : ModProjectile { - private const float PushawayForce = 0.05f; - public override void SetStaticDefaults() { DisplayName.SetDefault("Black Hawk"); @@ -37,45 +37,52 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { + //Set namespaces Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); + CalamityGlobalProjectile modProj = projectile.Calamity(); + + //On spawn effects if (projectile.localAI[0] == 0f) { - projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); - projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + //Set constants + modProj.spawnedPlayerMinionDamageValue = player.MinionDamage(); + modProj.spawnedPlayerMinionProjectileDamageValue = projectile.damage; + //Spawn dust + int dustAmt = 36; + for (int dustIndex = 0; dustIndex < dustAmt; dustIndex++) { - Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center; - Vector2 vector7 = vector6 - projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 258, vector7.X * 1.75f, vector7.Y * 1.75f, 100, default, 1.1f); - Main.dust[num228].noGravity = true; - Main.dust[num228].velocity = vector7; + Vector2 direction = Vector2.Normalize(projectile.velocity) * new Vector2(projectile.width / 2f, projectile.height) * 0.75f; + direction = direction.RotatedBy((double)((dustIndex - (dustAmt / 2f - 1f)) * MathHelper.TwoPi / dustAmt), default) + projectile.Center; + Vector2 dustVel = direction - projectile.Center; + int fire = Dust.NewDust(direction + dustVel, 0, 0, 258, dustVel.X * 1.75f, dustVel.Y * 1.75f, 100, default, 1.1f); + Main.dust[fire].noGravity = true; + Main.dust[fire].velocity = dustVel; } projectile.localAI[0] += 1f; } - if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + + //Flexible minion damage update + if (player.MinionDamage() != modProj.spawnedPlayerMinionDamageValue) { - int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / - projectile.Calamity().spawnedPlayerMinionDamageValue * - player.MinionDamage()); + int damage2 = (int)((float)modProj.spawnedPlayerMinionProjectileDamageValue / + modProj.spawnedPlayerMinionDamageValue * player.MinionDamage()); projectile.damage = damage2; } + + //Update frames projectile.frameCounter++; if (projectile.frameCounter >= 4) { projectile.frame++; projectile.frameCounter = 0; } - if (projectile.frame >= 3) + if (projectile.frame >= Main.projFrames[projectile.type]) { projectile.frame = 0; } - float num633 = 700f; - float num634 = 1300f; - float num635 = 2600f; - float num636 = 600f; + + //Set up buff and timeLeft bool flag64 = projectile.type == ModContent.ProjectileType(); player.AddBuff(ModContent.BuffType(), 3600); if (flag64) @@ -89,171 +96,203 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - for (int k = 0; k < Main.maxProjectiles; k++) - { - Projectile otherProj = Main.projectile[k]; - // Short circuits to make the loop as fast as possible - if (!otherProj.active || otherProj.owner != projectile.owner || !otherProj.minion || k == projectile.whoAmI) - continue; - // If the other projectile is indeed a Black Hawk owned by the same player and they're too close, nudge them away. - bool isBlackHawk = otherProj.type == projectile.type; - float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y); - if (isBlackHawk && taxicabDist < projectile.width) - { - if (projectile.position.X < otherProj.position.X) - projectile.velocity.X = projectile.velocity.X - PushawayForce; - else - projectile.velocity.X = projectile.velocity.X + PushawayForce; + //Anti sticky movement to prevent overlapping minions + projectile.MinionAntiClump(); - if (projectile.position.Y < otherProj.position.Y) - projectile.velocity.Y = projectile.velocity.Y - PushawayForce; - else - projectile.velocity.Y = projectile.velocity.Y + PushawayForce; - } - } - Vector2 vector46 = projectile.position; - bool flag25 = false; + float maxDistance = 700f; + Vector2 targetVec = projectile.position; + Vector2 half = new Vector2(0.5f); + bool foundTarget = false; + //If targeting something, prioritize that enemy if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; if (npc.CanBeChasedBy(projectile, false)) { - float num646 = Vector2.Distance(npc.Center, projectile.Center); - if (!flag25 && num646 < num633) + //Adding a check on the NPC's size allows it to target big things like Providence + Vector2 sizeCheck = npc.position + npc.Size * half; + //Calculate distance between target and the projectile to know if it's too far or not + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < maxDistance) { - vector46 = npc.Center; - flag25 = true; + maxDistance = targetDist; + targetVec = sizeCheck; + foundTarget = true; } } } else { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) { - NPC nPC2 = Main.npc[num645]; - if (nPC2.CanBeChasedBy(projectile, false)) + NPC npc = Main.npc[npcIndex]; + if (npc.CanBeChasedBy(projectile, false)) { - float num646 = Vector2.Distance(nPC2.Center, projectile.Center); - if (!flag25 && num646 < num633) + Vector2 sizeCheck = npc.position + npc.Size * half; + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < maxDistance) { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; + maxDistance = targetDist; + targetVec = sizeCheck; + foundTarget = true; } } } } - float num647 = num634; - if (flag25) + + //If too far, make the minion start returning to the player. + float separationAnxietyDist = 1300f; + if (foundTarget) { - num647 = num635; + //Max travel distance increases if targeting something + separationAnxietyDist = 2600f; } - if (Vector2.Distance(player.Center, projectile.Center) > num647) + if (Vector2.Distance(player.Center, projectile.Center) > separationAnxietyDist) { projectile.ai[0] = 1f; projectile.netUpdate = true; } - if (flag25 && projectile.ai[0] == 0f) + + //If a target is found, move toward it + if (foundTarget && projectile.ai[0] == 0f) { - Vector2 vector47 = vector46 - projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) + Vector2 vecToTarget = targetVec - projectile.Center; + float targetDist = vecToTarget.Length(); + vecToTarget.Normalize(); + //If farther than 200 pixels, move toward it + if (targetDist > 200f) { - float scaleFactor2 = 18f; //12 - vector47 *= scaleFactor2; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; + float speedMult = 18f; + vecToTarget *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; } + //Otherwise, back it up slowly else { - float num649 = 9f; - vector47 *= -num649; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; + float speedMult = -9f; + vecToTarget *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; } } + + //If not targeting something, act passively else { - bool flag26 = false; - if (!flag26) + bool returningToPlayer = false; + if (!returningToPlayer) { - flag26 = projectile.ai[0] == 1f; + returningToPlayer = projectile.ai[0] == 1f; } - float num650 = 12f; - if (flag26) + //Move faster if actively returning to the player + float speedMult = 12f; + if (returningToPlayer) { - num650 = 30f; + speedMult = 30f; } - Vector2 center2 = projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(0f, -120f); - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 16f) + Vector2 vecToPlayer = player.Center - projectile.Center + new Vector2(0f, -120f); + float playerDist = vecToPlayer.Length(); + //Speed up if near the player + if (playerDist < 200f && speedMult < 16f) { - num650 = 16f; + speedMult = 16f; } - if (num651 < num636 && flag26) + //If close enough to the player, return to normal + if (playerDist < 600f && returningToPlayer) { projectile.ai[0] = 0f; projectile.netUpdate = true; } - if (num651 > 2000f) + //If abnormally far, teleport to the player + if (playerDist > 2000f) { projectile.position.X = player.Center.X - (float)(projectile.width / 2); projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); projectile.netUpdate = true; } - if (num651 > 70f) + //Move toward player if more than 70 pixels away + if (playerDist > 70f) { - vector48.Normalize(); - vector48 *= num650; - projectile.velocity = (projectile.velocity * 40f + vector48) / 41f; + vecToPlayer.Normalize(); + vecToPlayer *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToPlayer) / 41f; } + //Move if still else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) { projectile.velocity.X = -0.15f; projectile.velocity.Y = -0.05f; } } - if (flag25) + + //Update rotation + if (foundTarget) { - projectile.rotation = (vector46 - projectile.Center).ToRotation() + 3.14159274f; + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + MathHelper.Pi, 0.1f); } else { - projectile.rotation = projectile.velocity.ToRotation() + 3.14159274f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi; } + + //Increment attack cooldown if (projectile.ai[1] > 0f) { - projectile.ai[1] += (float)Main.rand.Next(1, 4); + projectile.ai[1] += Main.rand.Next(1, 4); } + //Set the minion to be ready for attack if (projectile.ai[1] > 90f) { projectile.ai[1] = 0f; projectile.netUpdate = true; } - if (projectile.ai[0] == 0f) + + //Return if on attack cooldown, has no target, or returning to the player + if (projectile.ai[0] != 0f || !foundTarget || projectile.ai[1] != 0f) + return; + + //Shoot a bullet + if (Main.myPlayer == projectile.owner) { - float scaleFactor3 = 6f; - int num658 = ModContent.ProjectileType(); - if (flag25 && projectile.ai[1] == 0f) - { - Main.PlaySound(SoundID.Item20, projectile.Center); - projectile.ai[1] += 2f; - if (Main.myPlayer == projectile.owner) - { - Vector2 value19 = vector46 - projectile.Center; - value19.Normalize(); - value19 *= scaleFactor3; - _ = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value19.X, value19.Y, num658, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - projectile.netUpdate = true; - } - } + float projSpeed = 6f; + int projType = ModContent.ProjectileType(); + Main.PlaySound(SoundID.Item20, projectile.Center); + projectile.ai[1] += 2f; + Vector2 velocity = targetVec - projectile.Center; + velocity.Normalize(); + velocity *= projSpeed; + Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, projectile.knockBack, projectile.owner); + projectile.netUpdate = true; } } - public override bool CanDamage() + //Does no contact damage + public override bool CanDamage() => false; + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { + Texture2D texture = Main.projectileTexture[projectile.type]; + int frameHeight = texture.Height / Main.projFrames[projectile.type]; + int y6 = frameHeight * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f); return false; } + + //Pretty glowmask + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/BlackHawkGlow"); + int frameHeight = texture.Height / Main.projFrames[projectile.type]; + int y6 = frameHeight * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, frameHeight)), Color.White, projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f); + } } } diff --git a/Projectiles/Summon/BloodClotMinion.cs b/Projectiles/Summon/BloodClotMinion.cs index abdaff6b43..982d7bd55b 100644 --- a/Projectiles/Summon/BloodClotMinion.cs +++ b/Projectiles/Summon/BloodClotMinion.cs @@ -89,30 +89,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - for (int num534 = 0; num534 < Main.maxProjectiles; num534++) - { - if (num534 != projectile.whoAmI && Main.projectile[num534].active && Main.projectile[num534].owner == projectile.owner && - Main.projectile[num534].type == ModContent.ProjectileType() && - Math.Abs(projectile.position.X - Main.projectile[num534].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num534].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num534].position.X) - { - projectile.velocity.X = projectile.velocity.X - 0.05f; - } - else - { - projectile.velocity.X = projectile.velocity.X + 0.05f; - } - if (projectile.position.Y < Main.projectile[num534].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - 0.05f; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + 0.05f; - } - } - } + projectile.MinionAntiClump(); float num535 = projectile.position.X; float num536 = projectile.position.Y; float num537 = 1300f; diff --git a/Projectiles/Summon/BrimstoneElementalMinion.cs b/Projectiles/Summon/BrimstoneElementalMinion.cs index 2535a9eba8..a80580b3e7 100644 --- a/Projectiles/Summon/BrimstoneElementalMinion.cs +++ b/Projectiles/Summon/BrimstoneElementalMinion.cs @@ -102,30 +102,7 @@ namespace CalamityMod.Projectiles.Summon } float num633 = 700f; float num636 = 400f; //150 - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } + projectile.MinionAntiClump(); Vector2 vector46 = projectile.position; bool flag25 = false; if (projectile.ai[0] != 1f) diff --git a/Projectiles/Summon/BrittleStarMinion.cs b/Projectiles/Summon/BrittleStarMinion.cs index 4b1675e06e..29acb7e416 100644 --- a/Projectiles/Summon/BrittleStarMinion.cs +++ b/Projectiles/Summon/BrittleStarMinion.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Summon } projectile.rotation += projectile.velocity.X * 0.04f; - CalamityGlobalProjectile.ChargingMinionAI(projectile, 600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, false); + projectile.ChargingMinionAI(600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 9.5f, false, false); } public override bool OnTileCollide(Vector2 oldVelocity) => false; diff --git a/Projectiles/Summon/CalamariMinion.cs b/Projectiles/Summon/CalamariMinion.cs index a862090b95..e7d201fed8 100644 --- a/Projectiles/Summon/CalamariMinion.cs +++ b/Projectiles/Summon/CalamariMinion.cs @@ -134,32 +134,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.localAI[0] -= 1f; } - int num3; - for (int num534 = 0; num534 < Main.maxProjectiles; num534 = num3 + 1) - { - if (num534 != projectile.whoAmI && Main.projectile[num534].active && Main.projectile[num534].owner == projectile.owner && - Main.projectile[num534].type == ModContent.ProjectileType() && - Math.Abs(projectile.position.X - Main.projectile[num534].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num534].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num534].position.X) - { - projectile.velocity.X = projectile.velocity.X - 0.05f; - } - else - { - projectile.velocity.X = projectile.velocity.X + 0.05f; - } - if (projectile.position.Y < Main.projectile[num534].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - 0.05f; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + 0.05f; - } - } - num3 = num534; - } + projectile.MinionAntiClump(); Vector2 vector = projectile.position; float num10 = 3000f; //300 bool flag = false; diff --git a/Projectiles/Summon/Calamitamini.cs b/Projectiles/Summon/Calamitamini.cs index 1470c5ef20..7ac5313243 100644 --- a/Projectiles/Summon/Calamitamini.cs +++ b/Projectiles/Summon/Calamitamini.cs @@ -78,30 +78,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } + projectile.MinionAntiClump(); bool flag24 = false; if (flag24) { diff --git a/Projectiles/Summon/Cataclymini.cs b/Projectiles/Summon/Cataclymini.cs index 176ad6c9f0..c3dfac0236 100644 --- a/Projectiles/Summon/Cataclymini.cs +++ b/Projectiles/Summon/Cataclymini.cs @@ -77,30 +77,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } + projectile.MinionAntiClump(); bool flag24 = false; if (flag24) { diff --git a/Projectiles/Summon/Catastromini.cs b/Projectiles/Summon/Catastromini.cs index 22838ed06f..3232dff49a 100644 --- a/Projectiles/Summon/Catastromini.cs +++ b/Projectiles/Summon/Catastromini.cs @@ -86,7 +86,7 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } - CalamityGlobalProjectile.ChargingMinionAI(projectile, 700f, 1100f, 2400f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, true); + projectile.ChargingMinionAI(700f, 1100f, 2400f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, true); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Summon/CausticStaffSummon.cs b/Projectiles/Summon/CausticStaffSummon.cs index 8a691e51c9..6b8c0ea620 100644 --- a/Projectiles/Summon/CausticStaffSummon.cs +++ b/Projectiles/Summon/CausticStaffSummon.cs @@ -82,22 +82,7 @@ namespace CalamityMod.Projectiles.Summon } //Anti sticky movement to prevent minions from stacking - float antiStickyFloat = 0.05f; - for (int index = 0; index < Main.maxProjectiles; ++index) - { - Projectile proj = Main.projectile[index]; - if (index != projectile.whoAmI && proj.active && (proj.owner == projectile.owner && proj.type == projectile.type) && (double) Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) - { - if (projectile.position.X < proj.position.X) - projectile.velocity.X -= antiStickyFloat; - else - projectile.velocity.X += antiStickyFloat; - if (projectile.position.Y < proj.position.Y) - projectile.velocity.Y -= antiStickyFloat; - else - projectile.velocity.Y += antiStickyFloat; - } - } + projectile.MinionAntiClump(); //Set tile collision for only when trying to return to the player projectile.tileCollide = projectile.ai[0] != 1f; diff --git a/Projectiles/Summon/CloudElementalMinion.cs b/Projectiles/Summon/CloudElementalMinion.cs index d2f752e333..757990b8bf 100644 --- a/Projectiles/Summon/CloudElementalMinion.cs +++ b/Projectiles/Summon/CloudElementalMinion.cs @@ -101,7 +101,7 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } - CalamityGlobalProjectile.ChargingMinionAI(projectile, 500f, 800f, 1200f, 400f, 0, 30f, 8f, -4f, 40f, 8f, false, true); + projectile.ChargingMinionAI(500f, 800f, 1200f, 400f, 0, 30f, 8f, -4f, 40f, 8f, false, true); } } } diff --git a/Projectiles/Summon/CosmicEnergySpiral.cs b/Projectiles/Summon/CosmicEnergySpiral.cs index 45717ba2b1..64fe2da558 100644 --- a/Projectiles/Summon/CosmicEnergySpiral.cs +++ b/Projectiles/Summon/CosmicEnergySpiral.cs @@ -70,30 +70,6 @@ namespace CalamityMod.Projectiles.Summon float num634 = 1600f; //800 float num635 = 2400f; //1200 float num636 = 800f; - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } projectile.rotation += projectile.velocity.X * 0.1f; Vector2 vector46 = projectile.position; bool flag25 = false; diff --git a/Projectiles/Summon/CosmicViperGlow.png b/Projectiles/Summon/CosmicViperGlow.png new file mode 100644 index 0000000000..4f35f5fc00 Binary files /dev/null and b/Projectiles/Summon/CosmicViperGlow.png differ diff --git a/Projectiles/Summon/CosmicViperSummon.cs b/Projectiles/Summon/CosmicViperSummon.cs index 9964b27bfd..48d29995ab 100644 --- a/Projectiles/Summon/CosmicViperSummon.cs +++ b/Projectiles/Summon/CosmicViperSummon.cs @@ -92,31 +92,7 @@ namespace CalamityMod.Projectiles.Summon float colorScale = (float)projectile.alpha / 255f; Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, 1f * colorScale, 0.1f * colorScale, 1f * colorScale); - float antiStickyFloat = 0.05f; - for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) - { - Projectile proj = Main.projectile[projIndex]; - bool flag23 = proj.type == ModContent.ProjectileType(); - if (projIndex != projectile.whoAmI && proj.active && proj.owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X -= antiStickyFloat; - } - else - { - projectile.velocity.X += antiStickyFloat; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y -= antiStickyFloat; - } - else - { - projectile.velocity.Y += antiStickyFloat; - } - } - } + projectile.MinionAntiClump(); float detectRange = 700f; Vector2 targetVec = projectile.position; @@ -292,19 +268,31 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool CanDamage() => false; + public override bool CanDamage() => false; - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { Texture2D texture = Main.projectileTexture[projectile.type]; - int frameHeight = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int frameHeight = texture.Height / Main.projFrames[projectile.type]; int y6 = frameHeight * projectile.frame; SpriteEffects spriteEffects = SpriteEffects.None; if (projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f); - return false; + return false; + } + + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/CosmicViperGlow"); + int frameHeight = texture.Height / Main.projFrames[projectile.type]; + int y6 = frameHeight * projectile.frame; + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture.Width, frameHeight)), Color.White, projectile.rotation, new Vector2(texture.Width / 2f, frameHeight / 2f), projectile.scale, spriteEffects, 0f); } } } diff --git a/Projectiles/Summon/CosmilampMinion.cs b/Projectiles/Summon/CosmilampMinion.cs index 5480dfd431..17203f10dc 100644 --- a/Projectiles/Summon/CosmilampMinion.cs +++ b/Projectiles/Summon/CosmilampMinion.cs @@ -83,32 +83,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - int num3; - for (int num534 = 0; num534 < Main.maxProjectiles; num534 = num3 + 1) - { - if (num534 != projectile.whoAmI && Main.projectile[num534].active && Main.projectile[num534].owner == projectile.owner && - Main.projectile[num534].type == ModContent.ProjectileType() && - Math.Abs(projectile.position.X - Main.projectile[num534].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num534].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num534].position.X) - { - projectile.velocity.X = projectile.velocity.X - 0.05f; - } - else - { - projectile.velocity.X = projectile.velocity.X + 0.05f; - } - if (projectile.position.Y < Main.projectile[num534].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - 0.05f; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + 0.05f; - } - } - num3 = num534; - } + projectile.MinionAntiClump(); float num535 = projectile.position.X; float num536 = projectile.position.Y; float num537 = 3000f; @@ -142,7 +117,7 @@ namespace CalamityMod.Projectiles.Summon } else { - for (int num542 = 0; num542 < Main.maxNPCs; num542 = num3 + 1) + for (int num542 = 0; num542 < Main.maxNPCs; num542++) { if (Main.npc[num542].CanBeChasedBy(projectile, false)) { @@ -157,7 +132,6 @@ namespace CalamityMod.Projectiles.Summon flag19 = true; } } - num3 = num542; } } } @@ -168,9 +142,9 @@ namespace CalamityMod.Projectiles.Summon { num546 = 18f; } - Vector2 vector42 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num547 = Main.player[projectile.owner].Center.X - vector42.X; - float num548 = Main.player[projectile.owner].Center.Y - vector42.Y - 60f; + Vector2 vector42 = projectile.Center; + float num547 = player.Center.X - vector42.X; + float num548 = player.Center.Y - vector42.Y - 60f; float num549 = (float)Math.Sqrt((double)(num547 * num547 + num548 * num548)); if (num549 < 400f && projectile.ai[0] == 1f && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) { @@ -240,7 +214,7 @@ namespace CalamityMod.Projectiles.Summon } } projectile.rotation = projectile.velocity.X * 0.05f; - if ((double)Math.Abs(projectile.velocity.X) > 0.2) + if (Math.Abs(projectile.velocity.X) > 0.2f) { projectile.spriteDirection = -projectile.direction; return; diff --git a/Projectiles/Summon/DankCreeperMinion.cs b/Projectiles/Summon/DankCreeperMinion.cs index 38f8d3d8c6..0b171bea53 100644 --- a/Projectiles/Summon/DankCreeperMinion.cs +++ b/Projectiles/Summon/DankCreeperMinion.cs @@ -75,32 +75,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - int num3; - for (int num534 = 0; num534 < Main.maxProjectiles; num534 = num3 + 1) - { - if (num534 != projectile.whoAmI && Main.projectile[num534].active && Main.projectile[num534].owner == projectile.owner && - Main.projectile[num534].type == ModContent.ProjectileType() && - Math.Abs(projectile.position.X - Main.projectile[num534].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num534].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num534].position.X) - { - projectile.velocity.X = projectile.velocity.X - 0.05f; - } - else - { - projectile.velocity.X = projectile.velocity.X + 0.05f; - } - if (projectile.position.Y < Main.projectile[num534].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - 0.05f; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + 0.05f; - } - } - num3 = num534; - } + projectile.MinionAntiClump(); float num535 = projectile.position.X; float num536 = projectile.position.Y; float num537 = 1300f; @@ -134,7 +109,7 @@ namespace CalamityMod.Projectiles.Summon } else { - for (int num542 = 0; num542 < Main.maxNPCs; num542 = num3 + 1) + for (int num542 = 0; num542 < Main.maxNPCs; num542++) { if (Main.npc[num542].CanBeChasedBy(projectile, false)) { @@ -149,7 +124,6 @@ namespace CalamityMod.Projectiles.Summon flag19 = true; } } - num3 = num542; } } } diff --git a/Projectiles/Summon/DormantBrimseekerBab.cs b/Projectiles/Summon/DormantBrimseekerBab.cs index 3ea9f935e3..ff9228c5b2 100644 --- a/Projectiles/Summon/DormantBrimseekerBab.cs +++ b/Projectiles/Summon/DormantBrimseekerBab.cs @@ -110,32 +110,7 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = (projectile.localAI[1] == 1f).ToInt() * 4; } - float acceleration = 0.1f; - for (int index = 0; index < Main.projectile.Length; index++) - { - Projectile proj = Main.projectile[index]; - if (index != projectile.whoAmI && - proj.active && proj.owner == projectile.owner && - proj.type == projectile.type && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X -= acceleration; - } - else - { - projectile.velocity.X += acceleration; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y -= acceleration; - } - else - { - projectile.velocity.Y += acceleration; - } - } - } + projectile.MinionAntiClump(0.1f); if (projectile.Distance(player.Center) > 2700f) { projectile.Center = player.Center; diff --git a/Projectiles/Summon/ElementalAxeMinion.cs b/Projectiles/Summon/ElementalAxeMinion.cs index ce28882f0f..d1b0e7c858 100644 --- a/Projectiles/Summon/ElementalAxeMinion.cs +++ b/Projectiles/Summon/ElementalAxeMinion.cs @@ -70,7 +70,7 @@ namespace CalamityMod.Projectiles.Summon } projectile.rotation += 0.075f; - CalamityGlobalProjectile.ChargingMinionAI(projectile, 1600f, 1800f, 2500f, 400f, 1, 30f, 24f, -12f, 30f, 16f, true, true); + projectile.ChargingMinionAI(1600f, 1800f, 2500f, 400f, 1, 30f, 24f, -12f, 30f, 16f, true, true); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Summon/EndoCooperBody.cs b/Projectiles/Summon/EndoCooperBody.cs index ba3d445edc..17e694bac3 100644 --- a/Projectiles/Summon/EndoCooperBody.cs +++ b/Projectiles/Summon/EndoCooperBody.cs @@ -110,7 +110,6 @@ namespace CalamityMod.Projectiles.Summon float longdistance = AttackMode != 2 ? 1300f : 1200f; float longestdistance = AttackMode != 2 ? 2600f : 2500f; float idledistance = AttackMode != 2 ? 600f : 400f; - float SAImovement = 0.05f; float chasespeed1 = 30f; float chasespeed2 = 18f; float firerate = 30f; @@ -140,32 +139,8 @@ namespace CalamityMod.Projectiles.Summon if (limbs.type != ModContent.ProjectileType() || !limbs.active) projectile.Kill(); - - for (int num638 = 0; num638 < Main.projectile.Length; num638++) - { - Projectile proj = Main.projectile[num638]; - bool flag23 = proj.type == ModContent.ProjectileType(); - bool limbsfind = proj.type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && proj.active && proj.owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X -= SAImovement; - } - else - { - projectile.velocity.X += SAImovement; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y -= SAImovement; - } - else - { - projectile.velocity.Y += SAImovement; - } - } - } + + projectile.MinionAntiClump(); bool flag24 = false; if (projectile.ai[0] == 2f) { diff --git a/Projectiles/Summon/FungalClumpMinion.cs b/Projectiles/Summon/FungalClumpMinion.cs index 30f30591d3..56c2114325 100644 --- a/Projectiles/Summon/FungalClumpMinion.cs +++ b/Projectiles/Summon/FungalClumpMinion.cs @@ -95,31 +95,7 @@ namespace CalamityMod.Projectiles.Summon } //Anti-sticky movement failsafe - float SAIMovement = 0.05f; - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile proj = Main.projectile[i]; - bool typeCheck = proj.type == ModContent.ProjectileType(); - if (i != projectile.whoAmI && proj.active && proj.owner == projectile.owner && typeCheck && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < (float)projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X -= SAIMovement; - } - else - { - projectile.velocity.X += SAIMovement; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y -= SAIMovement; - } - else - { - projectile.velocity.Y += SAIMovement; - } - } - } + projectile.MinionAntiClump(); //If summoned by Amalgam, trail poisonous seawater if (Math.Abs(projectile.velocity.X) > 0.1f || Math.Abs(projectile.velocity.Y) > 0.1f) diff --git a/Projectiles/Summon/GastricBelcher.cs b/Projectiles/Summon/GastricBelcher.cs index a262d973a0..e189e999c6 100644 --- a/Projectiles/Summon/GastricBelcher.cs +++ b/Projectiles/Summon/GastricBelcher.cs @@ -104,31 +104,7 @@ namespace CalamityMod.Projectiles.Summon } //Anti sticky movement to prevent overlapping minions - float antiStickMvt = 0.05f; - for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) - { - Projectile proj = Main.projectile[projIndex]; - bool correctMinion = proj.type == ModContent.ProjectileType(); - if (projIndex != projectile.whoAmI && proj.active && proj.owner == projectile.owner && correctMinion && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X -= antiStickMvt; - } - else - { - projectile.velocity.X += antiStickMvt; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y -= antiStickMvt; - } - else - { - projectile.velocity.Y += antiStickMvt; - } - } - } + projectile.MinionAntiClump(); //Find a target float maxDistance = 700f; diff --git a/Projectiles/Summon/HerringMinion.cs b/Projectiles/Summon/HerringMinion.cs index 70170bf0da..36d87f9dba 100644 --- a/Projectiles/Summon/HerringMinion.cs +++ b/Projectiles/Summon/HerringMinion.cs @@ -93,7 +93,7 @@ namespace CalamityMod.Projectiles.Summon } } - CalamityGlobalProjectile.ChargingMinionAI(projectile, 600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 7f, false, true); + projectile.ChargingMinionAI(600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 7f, false, true); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Summon/HowlsHeartCalcifer.cs b/Projectiles/Summon/HowlsHeartCalcifer.cs index b1a47f7f6c..1cf16cd768 100644 --- a/Projectiles/Summon/HowlsHeartCalcifer.cs +++ b/Projectiles/Summon/HowlsHeartCalcifer.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Summon } } Lighting.AddLight(projectile.Center, 0.75f, 0.485f, 0f); - CalamityGlobalProjectile.FloatingPetAI(projectile, false, 0.04f, true); + projectile.FloatingPetAI(false, 0.04f, true); projectile.frameCounter++; if (projectile.frameCounter > 6) { diff --git a/Projectiles/Summon/HowlsHeartHowl.cs b/Projectiles/Summon/HowlsHeartHowl.cs index 42d0372e46..caf409d2de 100644 --- a/Projectiles/Summon/HowlsHeartHowl.cs +++ b/Projectiles/Summon/HowlsHeartHowl.cs @@ -85,22 +85,6 @@ namespace CalamityMod.Projectiles.Summon } //Anti sticky movement although there should only be one - float antiStickyFloat = 0.05f; - for (int index = 0; index < Main.maxProjectiles; ++index) - { - Projectile proj = Main.projectile[index]; - if (index != projectile.whoAmI && proj.active && (proj.owner == projectile.owner && proj.type == projectile.type) && (double)Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) - { - if (projectile.position.X < proj.position.X) - projectile.velocity.X -= antiStickyFloat; - else - projectile.velocity.X += antiStickyFloat; - if (projectile.position.Y < proj.position.Y) - projectile.velocity.Y -= antiStickyFloat; - else - projectile.velocity.Y += antiStickyFloat; - } - } //Set tile collision for only when trying to return to the player projectile.tileCollide = projectile.ai[0] != 1f; diff --git a/Projectiles/Summon/IceClasperMinion.cs b/Projectiles/Summon/IceClasperMinion.cs index b3b25e0066..b50e92bebc 100644 --- a/Projectiles/Summon/IceClasperMinion.cs +++ b/Projectiles/Summon/IceClasperMinion.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Summon } } - CalamityGlobalProjectile.ChargingMinionAI(projectile, 700f, 1000f, 2200f, 150f, 0, 40f, 9f, -4f, 40f, 9f, true, true); + projectile.ChargingMinionAI(700f, 1000f, 2200f, 150f, 0, 40f, 9f, -4f, 40f, 9f, true, true); projectile.rotation = projectile.velocity.ToRotation() - 1.57f; } diff --git a/Projectiles/Summon/IceSentryShard.cs b/Projectiles/Summon/IceSentryShard.cs index 379392a9e5..7a1f1de402 100644 --- a/Projectiles/Summon/IceSentryShard.cs +++ b/Projectiles/Summon/IceSentryShard.cs @@ -22,22 +22,11 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { DisplayName.SetDefault("Frost Shard"); - Main.projFrames[projectile.type] = 5; ProjectileID.Sets.SentryShot[projectile.type] = true; } public override void AI() { - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frameCounter = 0; - projectile.frame++; - } - - if (projectile.frame >= 5) - projectile.frame = 0; - projectile.velocity.Y += 0.2f; if (projectile.localAI[0] == 0f || projectile.localAI[0] == 2f) { diff --git a/Projectiles/Summon/LuxorsGiftSummon.cs b/Projectiles/Summon/LuxorsGiftSummon.cs index 24c948fd58..29066770e9 100644 --- a/Projectiles/Summon/LuxorsGiftSummon.cs +++ b/Projectiles/Summon/LuxorsGiftSummon.cs @@ -94,7 +94,7 @@ namespace CalamityMod.Projectiles.Summon } } - CalamityGlobalProjectile.ChargingMinionAI(projectile, 700f, 1000f, 2200f, 150f, 0, 40f, 9f, -4f, 40f, 9f, true, true); + projectile.ChargingMinionAI(700f, 1000f, 2200f, 150f, 0, 40f, 9f, -4f, 40f, 9f, true, true); projectile.rotation = projectile.velocity.ToRotation() + 1.57f; } diff --git a/Projectiles/Summon/MagicAxe.cs b/Projectiles/Summon/MagicAxe.cs index 89f3639975..c1c75c88fd 100644 --- a/Projectiles/Summon/MagicAxe.cs +++ b/Projectiles/Summon/MagicAxe.cs @@ -48,30 +48,7 @@ namespace CalamityMod.Projectiles.Summon projectile.alpha -= 50; float num634 = 1200f; float num635 = 2500f; - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.projectile.Length; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } + projectile.MinionAntiClump(); if (projectile.ai[1] <= 30) { projectile.ai[1]++; diff --git a/Projectiles/Summon/MagicBullet.cs b/Projectiles/Summon/MagicBullet.cs index 1864b8cf33..5e92de59ea 100644 --- a/Projectiles/Summon/MagicBullet.cs +++ b/Projectiles/Summon/MagicBullet.cs @@ -6,52 +6,59 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { public class MagicBullet : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bullet"); - ProjectileID.Sets.MinionShot[projectile.type] = true; - } + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bullet"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = 4; - projectile.height = 4; - projectile.light = 0.5f; - projectile.alpha = 255; - projectile.extraUpdates = 7; - projectile.scale = 1.18f; - projectile.friendly = true; - projectile.minion = true; - projectile.ignoreWater = true; - projectile.aiStyle = 1; - aiType = 242; - projectile.penetrate = 1; - projectile.timeLeft = 600; + public override void SetDefaults() + { + projectile.width = 4; + projectile.height = 4; + projectile.light = 0.5f; + projectile.alpha = 255; + projectile.extraUpdates = 7; + projectile.scale = 1.18f; + projectile.friendly = true; + projectile.minion = true; + projectile.ignoreWater = true; + projectile.aiStyle = 1; + aiType = ProjectileID.BulletHighVelocity; + projectile.penetrate = 1; + projectile.timeLeft = 600; projectile.tileCollide = false; - } + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.BetsysCurse, 180); - target.AddBuff(BuffID.Ichor, 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (!target.betsysCurse) + target.AddBuff(BuffID.BetsysCurse, 180); + if (!target.ichor) + target.AddBuff(BuffID.Ichor, 180); + if (target.Calamity().marked <= 0) + target.AddBuff(ModContent.BuffType(), 180); + if (target.Calamity().aCrunch <= 0) + target.AddBuff(ModContent.BuffType(), 180); + if (target.Calamity().wCleave <= 0) + target.AddBuff(ModContent.BuffType(), 180); + if (target.Calamity().wDeath <= 0) + target.AddBuff(ModContent.BuffType(), 180); + } - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(BuffID.BetsysCurse, 180); - target.AddBuff(BuffID.Ichor, 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.Ichor, 180); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(189, 51, 164, projectile.alpha); - } - } + public override Color? GetAlpha(Color lightColor) + { + return new Color(189, 51, 164, projectile.alpha); + } + } } diff --git a/Projectiles/Summon/MagicRifle.cs b/Projectiles/Summon/MagicRifle.cs index 28dd81754b..e59667cb4c 100644 --- a/Projectiles/Summon/MagicRifle.cs +++ b/Projectiles/Summon/MagicRifle.cs @@ -7,229 +7,230 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { public class MagicRifle : ModProjectile - { + { private int counter = 0; private bool canHome = false; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Rifle"); - ProjectileID.Sets.MinionShot[projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rifle"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = 30; - projectile.height = 30; - projectile.netImportant = true; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.minionSlots = 0f; - projectile.timeLeft = 180; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.minion = true; - } + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 0f; + projectile.timeLeft = 180; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.minion = true; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.projectile.Length; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } + public override void AI() + { + //Set player namespace + Player player = Main.player[projectile.owner]; + + //Anti sticky movement to prevent overlapping minions + projectile.MinionAntiClump(); + + //Try not to do anything at first if (counter <= 30) { counter++; canHome = true; } - float homingRange = MagicHat.Range; - float num634 = 1600f; - float num635 = 2600f; - float num636 = 600f; - Vector2 vector46 = projectile.position; - bool flag25 = false; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false) && canHome) - { - float num646 = Vector2.Distance(npc.Center, projectile.Center); - if (!flag25 && num646 < homingRange) - { - homingRange = num646; - vector46 = npc.Center; - flag25 = true; - } - } - } - else - { - for (int num645 = 0; num645 < Main.npc.Length; num645++) - { - NPC nPC2 = Main.npc[num645]; - if (nPC2.CanBeChasedBy(projectile, false) && canHome) - { - float num646 = Vector2.Distance(nPC2.Center, projectile.Center); - if (!flag25 && num646 < homingRange) - { - homingRange = num646; - vector46 = nPC2.Center; - flag25 = true; - } - } - } - } - float num647 = num634; - if (flag25) - { - num647 = num635; - } - if (Vector2.Distance(player.Center, projectile.Center) > num647) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } - if (flag25 && projectile.ai[0] == 0f) - { - Vector2 vector47 = vector46 - projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) - { - float scaleFactor2 = 18f; //12 - vector47 *= scaleFactor2; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; - } - else - { - float num649 = 9f; - vector47 *= -num649; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; - } - } - else - { - bool flag26 = false; - if (!flag26) - { - flag26 = projectile.ai[0] == 1f; - } - float num650 = 12f; - if (flag26) - { - num650 = 30f; - } - Vector2 center2 = projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(0f, -120f); - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 16f) - { - num650 = 16f; - } - if (num651 < num636 && flag26) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - if (num651 > 2000f) - { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } - if (num651 > 70f) - { - vector48.Normalize(); - vector48 *= num650; - projectile.velocity = (projectile.velocity * 40f + vector48) / 41f; - } - else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.15f; - projectile.velocity.Y = -0.05f; - } - } - if (flag25) - { - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = (vector46 - projectile.Center).ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(135)); - } - else - { - projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(135)); - } - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += (float)Main.rand.Next(1, 4); - } - if (projectile.ai[1] > 90f) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - if (projectile.ai[0] == 0f) - { - float scaleFactor3 = 6f; - int projType = ModContent.ProjectileType(); - if (flag25 && projectile.ai[1] == 0f) - { - if (Main.rand.NextBool(6)) + float homingRange = MagicHat.Range; + Vector2 targetVec = projectile.position; + Vector2 half = new Vector2(0.5f); + bool foundTarget = false; + //If targeting something, prioritize that enemy + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + if (npc.CanBeChasedBy(projectile, false) && canHome) + { + //Adding a check on the NPC's size allows it to target big things like Providence + Vector2 sizeCheck = npc.position + npc.Size * half; + //Calculate distance between target and the projectile to know if it's too far or not + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < homingRange) { - Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 20, 0.1f); + homingRange = targetDist; + targetVec = sizeCheck; + foundTarget = true; } - projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner) - { - Vector2 value19 = vector46 - projectile.Center; - value19.Normalize(); - value19 *= scaleFactor3; - Main.PlaySound(SoundID.Item40, projectile.position); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value19.X, value19.Y, projType, projectile.damage, 0f, Main.myPlayer, 0f, 0f); - projectile.netUpdate = true; - } - } - } - } + } + } + else + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + if (npc.CanBeChasedBy(projectile, false) && canHome) + { + Vector2 sizeCheck = npc.position + npc.Size * half; + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < homingRange) + { + homingRange = targetDist; + targetVec = sizeCheck; + foundTarget = true; + } + } + } + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(148, 0, 211, projectile.alpha); - } + //If too far, make the minion start returning to the player. + float separationAnxietyDist = 1600f; + if (foundTarget) + { + //Max travel distance increases if targeting something + separationAnxietyDist = 2600f; + } + if (Vector2.Distance(player.Center, projectile.Center) > separationAnxietyDist) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } - public override bool CanDamage() - { - return false; - } + //If a target is found, move toward it + if (foundTarget && projectile.ai[0] == 0f) + { + Vector2 vecToTarget = targetVec - projectile.Center; + float targetDist = vecToTarget.Length(); + vecToTarget.Normalize(); + //If farther than 200 pixels, move toward it + if (targetDist > 200f) + { + float speedMult = 18f; //12 + vecToTarget *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; + } + //Otherwise, back it up slowly + else + { + float speedMult = -9f; + vecToTarget *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToTarget) / 41f; + } + } - public override void Kill(int timeLeft) - { - for (int i = 0; i < 10; i++) - { - Vector2 dspeed = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f)); - int dust = Dust.NewDust(projectile.Center, 1, 1, 66, dspeed.X, dspeed.Y, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f); - Main.dust[dust].noGravity = true; - } - } - } + //If not targeting something, act passively + else + { + bool returningToPlayer = false; + if (!returningToPlayer) + { + returningToPlayer = projectile.ai[0] == 1f; + } + //Move faster if actively returning to the player + float speedMult = 12f; + if (returningToPlayer) + { + speedMult = 30f; + } + Vector2 vecToPlayer = player.Center - projectile.Center + new Vector2(0f, -120f); + float playerDist = vecToPlayer.Length(); + //Speed up if near the player + if (playerDist < 200f && speedMult < 16f) + { + speedMult = 16f; + } + //If close enough to the player, return to normal + if (playerDist < 600f && returningToPlayer) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + //If abnormally far, teleport to the player + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - (float)(projectile.width / 2); + projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + //Move toward player if more than 70 pixels away + if (playerDist > 70f) + { + vecToPlayer.Normalize(); + vecToPlayer *= speedMult; + projectile.velocity = (projectile.velocity * 40f + vecToPlayer) / 41f; + } + //Move if still + else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.velocity.X = -0.15f; + projectile.velocity.Y = -0.05f; + } + } + + //Update rotation + if (foundTarget) + { + projectile.spriteDirection = projectile.direction = ((targetVec.X - projectile.Center.X) > 0).ToDirectionInt(); + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(targetVec) + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(45) : MathHelper.ToRadians(135)), 0.1f); + } + else + { + projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(45) : MathHelper.ToRadians(135)); + } + + //Increment attack cooldown + if (projectile.ai[1] > 0f) + { + projectile.ai[1] += Main.rand.Next(1, 4); + } + //Set the minion to be ready for attack + if (projectile.ai[1] > 90f) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + + //Return if on attack cooldown, has no target, or returning to the player + if (projectile.ai[0] != 0f || !foundTarget || projectile.ai[1] != 0f) + return; + + //Shoot a bullet + if (Main.myPlayer == projectile.owner) + { + float projSpeed = 6f; + int projType = ModContent.ProjectileType(); + if (Main.rand.NextBool(6)) + { + Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 20, 0.1f); + } + projectile.ai[1] += 1f; + if (Main.myPlayer == projectile.owner) + { + Vector2 velocity = targetVec - projectile.Center; + velocity.Normalize(); + velocity *= projSpeed; + Main.PlaySound(SoundID.Item40, projectile.position); + Projectile.NewProjectile(projectile.Center, velocity, projType, projectile.damage, 0f, projectile.owner); + projectile.netUpdate = true; + } + } + } + + public override Color? GetAlpha(Color lightColor) => new Color(148, 0, 211, projectile.alpha); + + public override bool CanDamage() => false; + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 10; i++) + { + Vector2 dspeed = new Vector2(Main.rand.NextFloat(-7f, 7f), Main.rand.NextFloat(-7f, 7f)); + int dust = Dust.NewDust(projectile.Center, 1, 1, 66, dspeed.X, dspeed.Y, 160, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f); + Main.dust[dust].noGravity = true; + } + } + } } diff --git a/Projectiles/Summon/MagicUmbrella.cs b/Projectiles/Summon/MagicUmbrella.cs index ed47093b0a..6ee1a99dbe 100644 --- a/Projectiles/Summon/MagicUmbrella.cs +++ b/Projectiles/Summon/MagicUmbrella.cs @@ -45,31 +45,7 @@ namespace CalamityMod.Projectiles.Summon float num634 = 1600f; float num635 = 2200f; float num636 = 150f; - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.projectile.Length; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && - flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } + projectile.MinionAntiClump(); if (counter <= 30) { counter++; diff --git a/Projectiles/Summon/MidnightSunUFO.cs b/Projectiles/Summon/MidnightSunUFO.cs index e76c7ae6f6..e7ee1b1540 100644 --- a/Projectiles/Summon/MidnightSunUFO.cs +++ b/Projectiles/Summon/MidnightSunUFO.cs @@ -102,30 +102,7 @@ namespace CalamityMod.Projectiles.Summon ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); } - float acceleration = 0.35f; - for (int index = 0; index < Main.projectile.Length; index++) - { - Projectile proj = Main.projectile[index]; - if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X -= acceleration; - } - else - { - projectile.velocity.X += acceleration; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y -= acceleration; - } - else - { - projectile.velocity.Y += acceleration; - } - } - } + projectile.MinionAntiClump(0.35f); } else { @@ -162,30 +139,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.velocity = (projectile.velocity * 15f + projectile.DirectionTo(player.Center - new Vector2(player.direction * -80f, 160f)) * 19f) / 16f; - float acceleration = 0.35f; - for (int index = 0; index < Main.projectile.Length; index++) - { - Projectile proj = Main.projectile[index]; - if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X -= acceleration; - } - else - { - projectile.velocity.X += acceleration; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y -= acceleration; - } - else - { - projectile.velocity.Y += acceleration; - } - } - } + projectile.MinionAntiClump(0.35f); projectile.rotation = projectile.velocity.X * 0.03f; } } diff --git a/Projectiles/Summon/MiniGuardianAttack.cs b/Projectiles/Summon/MiniGuardianAttack.cs index d1243adabb..33161fc7c2 100644 --- a/Projectiles/Summon/MiniGuardianAttack.cs +++ b/Projectiles/Summon/MiniGuardianAttack.cs @@ -285,16 +285,16 @@ namespace CalamityMod.Projectiles.Summon else AI(1, num535, num536, player); } - if ((double)projectile.velocity.X > 0.25) + if (projectile.velocity.X > 0.25f) { projectile.direction = -1; } - else if ((double)projectile.velocity.X < -0.25) + else if (projectile.velocity.X < -0.25f) { projectile.direction = 1; } - if ((double)Math.Abs(projectile.velocity.X) > 0.2) + if (Math.Abs(projectile.velocity.X) > 0.2f) { projectile.spriteDirection = -projectile.direction; } diff --git a/Projectiles/Summon/MiniGuardianDefense.cs b/Projectiles/Summon/MiniGuardianDefense.cs index 388f980c70..1adb554fc5 100644 --- a/Projectiles/Summon/MiniGuardianDefense.cs +++ b/Projectiles/Summon/MiniGuardianDefense.cs @@ -283,16 +283,16 @@ namespace CalamityMod.Projectiles.Summon else AI(1, num535, num536, player); } - if ((double)projectile.velocity.X > 0.25) + if (projectile.velocity.X > 0.25f) { projectile.direction = -1; } - else if ((double)projectile.velocity.X < -0.25) + else if (projectile.velocity.X < -0.25f) { projectile.direction = 1; } - if ((double)Math.Abs(projectile.velocity.X) > 0.2) + if (Math.Abs(projectile.velocity.X) > 0.2f) { projectile.spriteDirection = -projectile.direction; } diff --git a/Projectiles/Summon/PhantomGuy.cs b/Projectiles/Summon/PhantomGuy.cs index 9f1f5e8449..4f1247aec7 100644 --- a/Projectiles/Summon/PhantomGuy.cs +++ b/Projectiles/Summon/PhantomGuy.cs @@ -72,30 +72,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } + projectile.MinionAntiClump(); float num633 = 3000f; float num634 = 3500f; float num635 = 4000f; diff --git a/Projectiles/Summon/PinkButterfly.cs b/Projectiles/Summon/PinkButterfly.cs index 0c3f9fca5c..7f9af97df4 100644 --- a/Projectiles/Summon/PinkButterfly.cs +++ b/Projectiles/Summon/PinkButterfly.cs @@ -92,30 +92,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } + projectile.MinionAntiClump(); bool flag24 = false; if (flag24) { diff --git a/Projectiles/Summon/PlaguePrincess.cs b/Projectiles/Summon/PlaguePrincess.cs index da7e5be419..b8fd4170ea 100644 --- a/Projectiles/Summon/PlaguePrincess.cs +++ b/Projectiles/Summon/PlaguePrincess.cs @@ -120,47 +120,24 @@ namespace CalamityMod.Projectiles.Summon } //anti sticking movement - float antiStickFloat = 0.05f; - for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) - { - Projectile proj = Main.projectile[projIndex]; - bool projCheck = proj.type == ModContent.ProjectileType(); - if (projIndex != projectile.whoAmI && proj.active && proj.owner == projectile.owner && projCheck && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < (float)projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X = projectile.velocity.X - antiStickFloat; - } - else - { - projectile.velocity.X = projectile.velocity.X + antiStickFloat; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - antiStickFloat; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + antiStickFloat; - } - } - } + projectile.MinionAntiClump(); //anti-sticking also applies to the player + float antiStickFloat = 0.05f; if (projectile.position.X < player.position.X) { - projectile.velocity.X = projectile.velocity.X - antiStickFloat; + projectile.velocity.X -= antiStickFloat; } else { - projectile.velocity.X = projectile.velocity.X + antiStickFloat; + projectile.velocity.X += antiStickFloat; } if (projectile.position.Y < player.position.Y) { - projectile.velocity.Y = projectile.velocity.Y - antiStickFloat; + projectile.velocity.Y -= antiStickFloat; } else { - projectile.velocity.Y = projectile.velocity.Y + antiStickFloat; + projectile.velocity.Y += antiStickFloat; } bool cancelAttack = false; diff --git a/Projectiles/Summon/PlaguebringerSummon.cs b/Projectiles/Summon/PlaguebringerSummon.cs index a0ce382e93..0f5a496e48 100644 --- a/Projectiles/Summon/PlaguebringerSummon.cs +++ b/Projectiles/Summon/PlaguebringerSummon.cs @@ -82,31 +82,7 @@ namespace CalamityMod.Projectiles.Summon if (!modPlayer.plaguebringerPatronSet) projectile.Kill(); - float SAIMovement = 0.05f; - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile proj = Main.projectile[i]; - bool minionTypeCheck = proj.type == ModContent.ProjectileType() || Main.projPet[proj.type]; - if (i != projectile.whoAmI && proj.active && proj.owner == projectile.owner && minionTypeCheck && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X -= SAIMovement; - } - else - { - projectile.velocity.X += SAIMovement; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y -= SAIMovement; - } - else - { - projectile.velocity.Y += SAIMovement; - } - } - } + projectile.MinionAntiClump(); int buffType = ModContent.BuffType(); float range = auraRange; diff --git a/Projectiles/Summon/PlantSummon.cs b/Projectiles/Summon/PlantSummon.cs index 0a541b502b..6c790344dc 100644 --- a/Projectiles/Summon/PlantSummon.cs +++ b/Projectiles/Summon/PlantSummon.cs @@ -119,32 +119,9 @@ namespace CalamityMod.Projectiles.Summon float num634 = 1300f; float num635 = 2600f; float num636 = 600f; - float num637 = 0.05f; //idle movement - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } + projectile.MinionAntiClump(); if (!enraged) { diff --git a/Projectiles/Summon/PurpleButterfly.cs b/Projectiles/Summon/PurpleButterfly.cs index d185e45d2a..0927822a9d 100644 --- a/Projectiles/Summon/PurpleButterfly.cs +++ b/Projectiles/Summon/PurpleButterfly.cs @@ -8,281 +8,104 @@ using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class PurpleButterfly : ModProjectile - { - public int dust = 3; + public class PurpleButterfly : ModProjectile + { + public int dust = 3; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Purple Butterfly"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.MinionSacrificable[projectile.type] = true; - ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Purple Butterfly"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } - public override void SetDefaults() - { - projectile.width = 30; - projectile.height = 30; - projectile.netImportant = true; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.minionSlots = 1f; - projectile.timeLeft = 18000; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.timeLeft *= 5; - projectile.minion = true; - } + public override void SetDefaults() + { + projectile.width = 30; + projectile.height = 30; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 1f; + projectile.timeLeft = 18000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft *= 5; + projectile.minion = true; + } - public override void AI() - { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - if (dust > 0) - { - projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); - projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) - { - Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.5f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center; - Vector2 vector7 = vector6 - projectile.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 173, vector7.X, vector7.Y, 100, default, 1.8f); - Main.dust[num228].noGravity = true; - } - dust--; - } - if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) - { - int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / - projectile.Calamity().spawnedPlayerMinionDamageValue * - player.MinionDamage()); - projectile.damage = damage2; - } - if ((double)Math.Abs(projectile.velocity.X) > 0.2) - { - projectile.spriteDirection = -projectile.direction; - } - projectile.rotation = projectile.velocity.X * 0.02f; - projectile.frameCounter++; - if (projectile.frameCounter > 6) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - { - projectile.frame = 0; - } - Lighting.AddLight(projectile.Center, 0.3f, 0f, 0.5f); - float num633 = 1200f; - float num634 = 1500f; - float num635 = 2400f; - float num636 = 150f; - bool flag64 = projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (flag64) - { - if (player.dead) - { - modPlayer.resButterfly = false; - } - if (modPlayer.resButterfly) - { - projectile.timeLeft = 2; - } - } - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && - flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } - bool flag24 = false; - if (projectile.ai[0] == 2f) - { - projectile.ai[1] += 1f; - projectile.extraUpdates = 1; - if (projectile.ai[1] > 30f) - { - projectile.ai[1] = 1f; - projectile.ai[0] = 0f; - projectile.extraUpdates = 0; - projectile.numUpdates = 0; - projectile.netUpdate = true; - } - else - { - flag24 = true; - } - } - if (flag24) - { - return; - } - Vector2 vector46 = projectile.position; - bool flag25 = false; - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if ((npc.CanBeChasedBy(projectile, false) || npc.type == NPCID.DukeFishron) && npc.active) - { - float num646 = Vector2.Distance(npc.Center, projectile.Center); - if (!flag25 && num646 < num633) - { - num633 = num646; - vector46 = npc.Center; - flag25 = true; - } - } - } - else - { - for (int num645 = 0; num645 < Main.maxNPCs; num645++) - { - NPC nPC2 = Main.npc[num645]; - if ((nPC2.CanBeChasedBy(projectile, false) || nPC2.type == NPCID.DukeFishron) && nPC2.active) - { - float num646 = Vector2.Distance(nPC2.Center, projectile.Center); - if (!flag25 && num646 < num633) - { - num633 = num646; - vector46 = nPC2.Center; - flag25 = true; - } - } - } - } - float num647 = num634; - if (flag25) - { - num647 = num635; - } - if (Vector2.Distance(player.Center, projectile.Center) > num647) - { - projectile.ai[0] = 1f; - projectile.netUpdate = true; - } - if (flag25 && projectile.ai[0] == 0f) - { - Vector2 vector47 = vector46 - projectile.Center; - float num648 = vector47.Length(); - vector47.Normalize(); - if (num648 > 200f) - { - float scaleFactor2 = 18f; - vector47 *= scaleFactor2; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; - } - else - { - float num649 = 9f; - vector47 *= -num649; - projectile.velocity = (projectile.velocity * 40f + vector47) / 41f; - } - } - else - { - bool flag26 = false; - if (!flag26) - { - flag26 = projectile.ai[0] == 1f; - } - float num650 = 10f; - if (flag26) - { - num650 = 24f; - } - Vector2 center2 = projectile.Center; - Vector2 vector48 = player.Center - center2 + new Vector2(40f, -40f); - float num651 = vector48.Length(); - if (num651 > 200f && num650 < 12f) - { - num650 = 12f; - } - if (num651 < num636 && flag26 && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - projectile.netUpdate = true; - } - if (num651 > 2000f) - { - projectile.position.X = player.Center.X - (float)(projectile.width / 2); - projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); - projectile.netUpdate = true; - } - if (num651 > 70f) - { - vector48.Normalize(); - vector48 *= num650; - projectile.velocity = (projectile.velocity * 40f + vector48) / 41f; - } - else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) - { - projectile.velocity.X = -0.15f; - projectile.velocity.Y = -0.05f; - } - } - if (projectile.ai[1] > 0f) - { - projectile.ai[1] += (float)Main.rand.Next(1, 3); - } - if (projectile.ai[1] > 30f) - { - projectile.ai[1] = 0f; - projectile.netUpdate = true; - } - if (projectile.ai[0] == 0f) - { - if (projectile.ai[1] == 0f && flag25 && num633 < 300f) - { - projectile.ai[1] += 1f; - if (Main.myPlayer == projectile.owner) - { - projectile.ai[0] = 2f; - Vector2 value20 = vector46 - projectile.Center; - value20.Normalize(); - projectile.velocity = value20 * 12f; - projectile.netUpdate = true; - } - } - } - } + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + if (dust > 0) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + int num226 = 36; + for (int num227 = 0; num227 < num226; num227++) + { + Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.5f; + vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center; + Vector2 vector7 = vector6 - projectile.Center; + int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 173, vector7.X, vector7.Y, 100, default, 1.8f); + Main.dust[num228].noGravity = true; + } + dust--; + } + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + player.MinionDamage()); + projectile.damage = damage2; + } + if (Math.Abs(projectile.velocity.X) > 0.2f) + { + projectile.spriteDirection = -projectile.direction; + } + projectile.rotation = projectile.velocity.X * 0.02f; + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + { + projectile.frame = 0; + } + Lighting.AddLight(projectile.Center, 0.3f, 0f, 0.5f); + projectile.ChargingMinionAI(1200f, 1500f, 2400f, 150f, 0, 30f, 18f, -9f, 30f, 12f, true, true); + bool flag64 = projectile.type == ModContent.ProjectileType(); + player.AddBuff(ModContent.BuffType(), 3600); + if (flag64) + { + if (player.dead) + { + modPlayer.resButterfly = false; + } + if (modPlayer.resButterfly) + { + projectile.timeLeft = 2; + } + } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Texture2D texture2D13 = Main.projectileTexture[projectile.type]; - int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; - int y6 = num214 * projectile.frame; - Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, spriteEffects, 0f); - return false; - } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D texture2D13 = Main.projectileTexture[projectile.type]; + int num214 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; + int y6 = num214 * projectile.frame; + Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, spriteEffects, 0f); + return false; + } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 6; - } - } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.immune[projectile.owner] = 6; + } + } } diff --git a/Projectiles/Summon/RustyDrone.cs b/Projectiles/Summon/RustyDrone.cs index db44011621..042137dfe4 100644 --- a/Projectiles/Summon/RustyDrone.cs +++ b/Projectiles/Summon/RustyDrone.cs @@ -15,9 +15,9 @@ namespace CalamityMod.Projectiles.Summon public const float NPCHomingInertia = 20f; public const float NPCHomingSpeed = 14f; - public const float AttackRate = 110f; + public const float AttackRate = 140f; - public const float DistanceToCheck = 750f; + public const float DistanceToCheck = 585f; public const int ExplosionShrapnelBaseDamage = 16; // Uses player.MinionDamage @@ -138,7 +138,7 @@ namespace CalamityMod.Projectiles.Summon Utils.PoofOfSmoke(projectile.Center); for (int i = 0; i < 4; i++) { - Projectile.NewProjectile(projectile.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * 8f, ModContent.ProjectileType(), + Projectile.NewProjectile(projectile.Center, Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * 8f, ModContent.ProjectileType(), (int)(ExplosionShrapnelBaseDamage * player.MinionDamage()), 2f, projectile.owner); } projectile.Kill(); diff --git a/Projectiles/Summon/SandElementalHealer.cs b/Projectiles/Summon/SandElementalHealer.cs index da82cdfa6e..ffa5c68efd 100644 --- a/Projectiles/Summon/SandElementalHealer.cs +++ b/Projectiles/Summon/SandElementalHealer.cs @@ -101,30 +101,7 @@ namespace CalamityMod.Projectiles.Summon float num = (float)Main.rand.Next(90, 111) * 0.01f; num *= Main.essScale; Lighting.AddLight(projectile.Center, 0.7f * num, 0.6f * num, 0f * num); - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } + projectile.MinionAntiClump(); if (Vector2.Distance(player.Center, projectile.Center) > 400f) { projectile.ai[0] = 1f; diff --git a/Projectiles/Summon/SandElementalMinion.cs b/Projectiles/Summon/SandElementalMinion.cs index b7237d3873..2f60590d2d 100644 --- a/Projectiles/Summon/SandElementalMinion.cs +++ b/Projectiles/Summon/SandElementalMinion.cs @@ -93,30 +93,7 @@ namespace CalamityMod.Projectiles.Summon float num = (float)Main.rand.Next(90, 111) * 0.01f; num *= Main.essScale; Lighting.AddLight(projectile.Center, 0.7f * num, 0.6f * num, 0f * num); - float num637 = 0.05f; - for (int num638 = 0; num638 < Main.maxProjectiles; num638++) - { - bool flag23 = Main.projectile[num638].type == ModContent.ProjectileType(); - if (num638 != projectile.whoAmI && Main.projectile[num638].active && Main.projectile[num638].owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - Main.projectile[num638].position.X) + Math.Abs(projectile.position.Y - Main.projectile[num638].position.Y) < (float)projectile.width) - { - if (projectile.position.X < Main.projectile[num638].position.X) - { - projectile.velocity.X = projectile.velocity.X - num637; - } - else - { - projectile.velocity.X = projectile.velocity.X + num637; - } - if (projectile.position.Y < Main.projectile[num638].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num637; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num637; - } - } - } + projectile.MinionAntiClump(); Vector2 vector46 = projectile.position; bool flag25 = false; if (projectile.ai[0] != 1f) diff --git a/Projectiles/Summon/SandnadoMinion.cs b/Projectiles/Summon/SandnadoMinion.cs index 97a1517504..059388b415 100644 --- a/Projectiles/Summon/SandnadoMinion.cs +++ b/Projectiles/Summon/SandnadoMinion.cs @@ -77,33 +77,9 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - float num8 = 0.1f; - float num9 = (float)projectile.width * 2f; - for (int j = 0; j < Main.maxProjectiles; j++) - { - if (j != projectile.whoAmI && Main.projectile[j].active && Main.projectile[j].owner == projectile.owner && Main.projectile[j].type == projectile.type && - Math.Abs(projectile.position.X - Main.projectile[j].position.X) + Math.Abs(projectile.position.Y - Main.projectile[j].position.Y) < num9) - { - if (projectile.position.X < Main.projectile[j].position.X) - { - projectile.velocity.X = projectile.velocity.X - num8; - } - else - { - projectile.velocity.X = projectile.velocity.X + num8; - } - if (projectile.position.Y < Main.projectile[j].position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - num8; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + num8; - } - } - } + projectile.MinionAntiClump(0.1f); Vector2 vector = projectile.position; - float num10 = 900f; + float num10 = 1200f; bool flag = false; if (Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) { @@ -157,12 +133,12 @@ namespace CalamityMod.Projectiles.Summon } } } - int num16 = 750; + float num16 = 1000f; if (flag) { - num16 = 2000; + num16 = 2500f; } - if (Vector2.Distance(player.Center, projectile.Center) > (float)num16) + if (Vector2.Distance(player.Center, projectile.Center) > num16) { projectile.ai[0] = 1f; projectile.netUpdate = true; diff --git a/Projectiles/Summon/SonOfYharon.cs b/Projectiles/Summon/SonOfYharon.cs index 09870b4627..4a2c8758ab 100644 --- a/Projectiles/Summon/SonOfYharon.cs +++ b/Projectiles/Summon/SonOfYharon.cs @@ -107,7 +107,7 @@ namespace CalamityMod.Projectiles.Summon } } - CalamityGlobalProjectile.ChargingMinionAI(projectile, 1000f, 2000f, 3000f, 500f, 1, 30f, 8f, -4f, 40f, 8f, true, true); + projectile.ChargingMinionAI(1000f, 2000f, 3000f, 500f, 1, 30f, 8f, -4f, 40f, 8f, true, true); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Summon/TacticalPlagueEngineSummon.cs b/Projectiles/Summon/TacticalPlagueEngineSummon.cs index d462974ff6..253acc9c81 100644 --- a/Projectiles/Summon/TacticalPlagueEngineSummon.cs +++ b/Projectiles/Summon/TacticalPlagueEngineSummon.cs @@ -168,32 +168,7 @@ namespace CalamityMod.Projectiles.Summon } } } - float SAImovement = 0.25f; - for (int index = 0; index < Main.projectile.Length; index++) - { - Projectile proj = Main.projectile[index]; - if (index != projectile.whoAmI && - proj.active && proj.owner == projectile.owner && - proj.type == projectile.type && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X -= SAImovement; - } - else - { - projectile.velocity.X += SAImovement; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y -= SAImovement; - } - else - { - projectile.velocity.Y += SAImovement; - } - } - } + projectile.MinionAntiClump(0.25f); } } diff --git a/Projectiles/Summon/Valkyrie.cs b/Projectiles/Summon/Valkyrie.cs index 3260742985..0c492c0bc0 100644 --- a/Projectiles/Summon/Valkyrie.cs +++ b/Projectiles/Summon/Valkyrie.cs @@ -83,7 +83,7 @@ namespace CalamityMod.Projectiles.Summon projectile.spriteDirection = -projectile.direction; } - CalamityGlobalProjectile.ChargingMinionAI(projectile, 700f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, true); + projectile.ChargingMinionAI(700f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 8f, false, true); //Give off some light float lightScalar = (float)Main.rand.Next(90, 111) * 0.01f; diff --git a/Projectiles/Summon/VileFeederSummon.cs b/Projectiles/Summon/VileFeederSummon.cs index 57d908f2f7..f226988dca 100644 --- a/Projectiles/Summon/VileFeederSummon.cs +++ b/Projectiles/Summon/VileFeederSummon.cs @@ -90,31 +90,7 @@ namespace CalamityMod.Projectiles.Summon player.MinionDamage()); projectile.damage = damage2; } - float antiStickyFloat = 0.05f; - for (int index = 0; index < Main.maxProjectiles; index++) - { - Projectile proj = Main.projectile[index]; - bool flag23 = proj.type == ModContent.ProjectileType(); - if (index != projectile.whoAmI && proj.active && proj.owner == projectile.owner && flag23 && Math.Abs(projectile.position.X - proj.position.X) + Math.Abs(projectile.position.Y - proj.position.Y) < (float)projectile.width) - { - if (projectile.position.X < proj.position.X) - { - projectile.velocity.X = projectile.velocity.X - antiStickyFloat; - } - else - { - projectile.velocity.X = projectile.velocity.X + antiStickyFloat; - } - if (projectile.position.Y < proj.position.Y) - { - projectile.velocity.Y = projectile.velocity.Y - antiStickyFloat; - } - else - { - projectile.velocity.Y = projectile.velocity.Y + antiStickyFloat; - } - } - } + projectile.MinionAntiClump(); projectile.frameCounter++; if (projectile.frameCounter > 3) { diff --git a/Projectiles/Summon/WulfrumDroid.cs b/Projectiles/Summon/WulfrumDroid.cs index 8e27dc9cfc..cbc19cb5d6 100644 --- a/Projectiles/Summon/WulfrumDroid.cs +++ b/Projectiles/Summon/WulfrumDroid.cs @@ -87,22 +87,7 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } - float num6 = 0.05f; - float width = (float) projectile.width; - for (int index = 0; index < Main.maxProjectiles; ++index) - { - if (index != projectile.whoAmI && Main.projectile[index].active && (Main.projectile[index].owner == projectile.owner && Main.projectile[index].type == projectile.type) && (double) Math.Abs(projectile.position.X - Main.projectile[index].position.X) + (double) Math.Abs(projectile.position.Y - Main.projectile[index].position.Y) < (double) width) - { - if ((double) projectile.position.X < (double) Main.projectile[index].position.X) - projectile.velocity.X -= num6; - else - projectile.velocity.X += num6; - if ((double) projectile.position.Y < (double) Main.projectile[index].position.Y) - projectile.velocity.Y -= num6; - else - projectile.velocity.Y += num6; - } - } + projectile.MinionAntiClump(); Vector2 vector2_3 = projectile.position; float num7 = 450f; bool flag = false; diff --git a/Projectiles/Typeless/FiniteUse/GrenadeRound.cs b/Projectiles/Typeless/FiniteUse/GrenadeRound.cs index 4c7eb86114..a4c1a88fbf 100644 --- a/Projectiles/Typeless/FiniteUse/GrenadeRound.cs +++ b/Projectiles/Typeless/FiniteUse/GrenadeRound.cs @@ -61,19 +61,7 @@ namespace CalamityMod.Projectiles.Typeless.FiniteUse public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - if (target.HitSound != SoundID.NPCHit1 && target.HitSound != SoundID.NPCHit6 && target.HitSound != SoundID.NPCHit7 && - target.HitSound != SoundID.NPCHit8 && target.HitSound != SoundID.NPCHit9 && target.HitSound != SoundID.NPCHit12 && - target.HitSound != SoundID.NPCHit13 && target.HitSound != SoundID.NPCHit14 && target.HitSound != SoundID.NPCHit18 && - target.HitSound != SoundID.NPCHit19 && target.HitSound != SoundID.NPCHit20 && target.HitSound != SoundID.NPCHit21 && - target.HitSound != SoundID.NPCHit22 && target.HitSound != SoundID.NPCHit23 && target.HitSound != SoundID.NPCHit24 && - target.HitSound != SoundID.NPCHit25 && target.HitSound != SoundID.NPCHit26 && target.HitSound != SoundID.NPCHit27 && - target.HitSound != SoundID.NPCHit28 && target.HitSound != SoundID.NPCHit29 && target.HitSound != SoundID.NPCHit31 && - target.HitSound != SoundID.NPCHit32 && target.HitSound != SoundID.NPCHit33 && target.HitSound != SoundID.NPCHit35 && - target.HitSound != SoundID.NPCHit37 && target.HitSound != SoundID.NPCHit38 && target.HitSound != SoundID.NPCHit40 && - target.HitSound != SoundID.NPCHit43 && target.HitSound != SoundID.NPCHit44 && target.HitSound != SoundID.NPCHit45 && - target.HitSound != SoundID.NPCHit46 && target.HitSound != SoundID.NPCHit47 && target.HitSound != SoundID.NPCHit48 && - target.HitSound != SoundID.NPCHit50 && target.HitSound != SoundID.NPCHit51 && target.HitSound != SoundID.NPCHit55 && - target.HitSound != SoundID.NPCHit56 && target.HitSound != SoundID.NPCHit57) + if (target.Inorganic()) { damage += target.lifeMax / 20; //500 + 200 = 700 + (100000 / 20 = 5000) = 5700 * 2 (explosion) = 11400 = 11.4% of boss HP } diff --git a/Projectiles/Typeless/FiniteUse/MagnumRound.cs b/Projectiles/Typeless/FiniteUse/MagnumRound.cs index bedca6384a..42422f79ae 100644 --- a/Projectiles/Typeless/FiniteUse/MagnumRound.cs +++ b/Projectiles/Typeless/FiniteUse/MagnumRound.cs @@ -1,6 +1,4 @@ using CalamityMod.CalPlayer; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.Providence; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -31,12 +29,7 @@ namespace CalamityMod.Projectiles.Typeless.FiniteUse public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - if ((target.HitSound != SoundID.NPCHit4 && target.HitSound != SoundID.NPCHit41 && target.HitSound != SoundID.NPCHit2 && - target.HitSound != SoundID.NPCHit5 && target.HitSound != SoundID.NPCHit11 && target.HitSound != SoundID.NPCHit30 && - target.HitSound != SoundID.NPCHit34 && target.HitSound != SoundID.NPCHit36 && target.HitSound != SoundID.NPCHit42 && - target.HitSound != SoundID.NPCHit49 && target.HitSound != SoundID.NPCHit52 && target.HitSound != SoundID.NPCHit53 && - target.HitSound != SoundID.NPCHit54 && target.HitSound != null) || target.type == ModContent.NPCType() || - target.type == ModContent.NPCType() || target.type == ModContent.NPCType()) + if (target.Organic()) { damage += target.lifeMax / 25; //400 + 80 = 480 + (100000 / 25 = 4000) = 4480, if crit = 5600 = 5.6% of boss HP } diff --git a/Tiles/Abyss/RustyChestLocked.cs b/Tiles/Abyss/RustyChestLocked.cs deleted file mode 100644 index 9391ea2eb8..0000000000 --- a/Tiles/Abyss/RustyChestLocked.cs +++ /dev/null @@ -1,124 +0,0 @@ -using CalamityMod.Dusts; -using CalamityMod.Items; -using CalamityMod.Items.Placeables.Furniture; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles.Abyss -{ - public class RustyChestLocked : ModTile - { - public override void SetDefaults() - { - this.SetUpChest(); - ModTranslation name = CreateMapEntryName("chestRusty"); - name.SetDefault("Rusty Chest"); - AddMapEntry(new Color(57, 48, 83), name, MapChestName); - dustType = ModContent.DustType(); - disableSmartCursor = true; - adjTiles = new int[] { TileID.Containers }; - chest = "Rusty Chest"; - chestDrop = ModContent.ItemType(); - } - - public override bool HasSmartInteract() => true; - - public override bool IsLockedChest(int i, int j) => Main.tile[i, j].frameX / 36 == 1; - - public override bool UnlockChest(int i, int j, ref short frameXAdjustment, ref int dustType, ref bool manual) - { - Player closest = Main.player[Player.FindClosest(new Vector2(i, j) * 16f, 1, 1)]; - if (!closest.InventoryHas(ModContent.ItemType())) - return false; - - for (int k = 0; k < closest.inventory.Length; k++) - { - if (closest.inventory[k].type == ModContent.ItemType()) - { - if (ItemLoader.ConsumeItem(closest.inventory[k], closest)) - { - closest.inventory[k].stack--; - } - if (closest.inventory[k].stack <= 0) - { - closest.inventory[k] = new Item(); - } - break; - } - } - - dustType = this.dustType; - - return true; - } - - public string MapChestName(string name, int i, int j) - { - // Bounds check - if (i < 0 || i >= Main.maxTilesX || j < 0 || j >= Main.maxTilesY) - return name; - - // Tile null check - Tile tile = Main.tile[i, j]; - if (tile is null) - return name; - - int left = i; - int top = j; - if (tile.frameX % 36 != 0) - left--; - if (tile.frameY != 0) - top--; - - int chest = Chest.FindChest(left, top); - return name + (Main.chest[chest].name != "" ? ": " + Main.chest[chest].name : ""); - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = 1; - } - - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(i * 16, j * 16, 32, 32, chestDrop); - Chest.DestroyChest(i, j); - } - - public override bool NewRightClick(int i, int j) - { - Tile tile = Main.tile[i, j]; - - int left = i; - int top = j; - - if (tile.frameX % 36 != 0) - { - left--; - } - if (tile.frameY != 0) - { - top--; - } - return CalamityUtils.LockedChestRightClick(IsLockedChest(left, top), left, top, i, j); - } - - public override void MouseOver(int i, int j) - { - if (IsLockedChest(i, j)) - CalamityUtils.ChestMouseOver("Rusty Chest", i, j); - else - CalamityUtils.ChestMouseOver("Rusty Chest", i, j); - } - - public override void MouseOverFar(int i, int j) - { - if (IsLockedChest(i, j)) - CalamityUtils.ChestMouseFar("Rusty Chest", i, j); - else - CalamityUtils.ChestMouseFar("Rusty Chest", i, j); - } - } -} diff --git a/Tiles/Abyss/RustyChestLocked.png b/Tiles/Abyss/RustyChestLocked.png deleted file mode 100644 index e88cc3af08..0000000000 Binary files a/Tiles/Abyss/RustyChestLocked.png and /dev/null differ diff --git a/Tiles/Abyss/RustyChestLocked_Highlight.png b/Tiles/Abyss/RustyChestLocked_Highlight.png deleted file mode 100644 index 94e49a2c3d..0000000000 Binary files a/Tiles/Abyss/RustyChestLocked_Highlight.png and /dev/null differ diff --git a/Tiles/Abyss/RustyChestTile.cs b/Tiles/Abyss/RustyChestTile.cs new file mode 100644 index 0000000000..4111461e82 --- /dev/null +++ b/Tiles/Abyss/RustyChestTile.cs @@ -0,0 +1,81 @@ +using CalamityMod.Items.Placeables.Furniture; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Abyss +{ + public class RustyChestTile : ModTile + { + public override void SetDefaults() + { + this.SetUpChest(); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Rusty Chest"); + AddMapEntry(new Color(191, 142, 111), name, MapChestName); + disableSmartCursor = true; + adjTiles = new int[] { TileID.Containers }; + chest = "Rusty Chest"; + chestDrop = ModContent.ItemType(); + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 180, 0f, 0f, 1, new Color(255, 255, 255), 1f); + return false; + } + + public override bool HasSmartInteract() => true; + + public string MapChestName(string name, int i, int j) + { + // Bounds check + if (i < 0 || i >= Main.maxTilesX || j < 0 || j >= Main.maxTilesY) + return name; + + // Tile null check + Tile tile = Main.tile[i, j]; + if (tile is null) + return name; + + int left = i; + int top = j; + if (tile.frameX % 36 != 0) + left--; + if (tile.frameY != 0) + top--; + + int chest = Chest.FindChest(left, top); + if (chest == -1) + return name; + return name + (Main.chest[chest].name != "" ? ": " + Main.chest[chest].name : ""); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(i * 16, j * 16, 32, 32, chestDrop); + Chest.DestroyChest(i, j); + } + + public override bool NewRightClick(int i, int j) + { + return CalamityUtils.ChestRightClick(i, j); + } + + public override void MouseOver(int i, int j) + { + CalamityUtils.ChestMouseOver("Rusty Chest", i, j); + } + + public override void MouseOverFar(int i, int j) + { + CalamityUtils.ChestMouseFar("Rusty Chest", i, j); + } + } +} diff --git a/Tiles/Abyss/RustyChestTile.png b/Tiles/Abyss/RustyChestTile.png new file mode 100644 index 0000000000..56fa385bc1 Binary files /dev/null and b/Tiles/Abyss/RustyChestTile.png differ diff --git a/Tiles/Abyss/RustyChestTile_Highlight.png b/Tiles/Abyss/RustyChestTile_Highlight.png new file mode 100644 index 0000000000..e530745085 Binary files /dev/null and b/Tiles/Abyss/RustyChestTile_Highlight.png differ diff --git a/Tiles/Furniture/AuricToiletTile.cs b/Tiles/Furniture/AuricToiletTile.cs index dfadd9a8e3..648cd8eab0 100644 --- a/Tiles/Furniture/AuricToiletTile.cs +++ b/Tiles/Furniture/AuricToiletTile.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Tiles.Furniture TileObjectData.newTile.StyleHorizontal = true; TileObjectData.newTile.Origin = new Point16(1, 1); TileObjectData.newTile.UsesCustomCanPlace = true; - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 4, 0); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 2, 0); TileObjectData.newTile.LavaDeath = false; TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight; diff --git a/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs b/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs index 49e4b83c8e..e7a37e66cc 100644 --- a/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs +++ b/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs @@ -1,6 +1,8 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables.LivingFire; using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -9,38 +11,88 @@ using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.LivingFire { - public class LivingBrimstoneFireBlockTile : ModTile - { - public override void SetDefaults() - { - Main.tileLighted[Type] = true; - soundType = SoundID.Dig; - drop = ModContent.ItemType(); - AddMapEntry(new Color(178, 34, 34)); - animationFrameHeight = 90; - TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.EmptyTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.EmptyTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.EmptyTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.EmptyTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.UsesCustomCanPlace = false; - } + public class LivingBrimstoneFireBlockTile : ModTile + { + //Thank you to Seraph for getting living fire blocks to work properly. + public override void SetDefaults() + { + Main.tileLighted[Type] = true; + soundType = SoundID.Dig; + drop = ModContent.ItemType(); + AddMapEntry(new Color(178, 34, 34)); + animationFrameHeight = 90; + Main.tileSolid[Type] = false; + Main.tileNoAttach[Type] = false; + Main.tileFrameImportant[Type] = false; + TileObjectData.newTile.Width = 1; + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.HookCheck = new PlacementHook(CanPlaceAlter, -1, 0, true ); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); - public override void AnimateTile(ref int frame, ref int frameCounter) - { + TileObjectData.addTile(Type); + } + + public int CanPlaceAlter(int i, int j, int type, int style, int direction) => 1; + + public static int AfterPlacement(int i, int j, int type, int style, int direction) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileRange(Main.myPlayer, i, j, 1, 1); + } + return 1; + } + + public override bool CanPlace(int i, int j) + { + List> around = new List> + { + new List() {i, j-1 }, + new List() {i-1, j }, + new List() {i+1, j }, + new List() {i, j+1 } + }; + //if (Main.tile[i, j]) || tile.type == Type + + //return true; //temporary for testing purposes + + if (Main.tile[i, j].wall != WallID.None) + { + return true; + } + + for (int k = 0; k < around.Count; ++k) + { + Tile tile = Main.tile[around[k][0], around[k][1]]; + if (tile.active() && (Main.tileSolid[tile.type] || CalamityMod.livingFireBlockList.Contains(tile.type))) + { + return true; + } + } + return false; + } + + public override void AnimateTile(ref int frame, ref int frameCounter) + { frame = Main.tileFrame[TileID.LivingFire]; - } + } - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { r = 1f; g = 0f; b = 0f; - } + } - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.Brimstone, 0f, 0f, 1, default, 1f); - return false; - } - } + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.Brimstone, 0f, 0f, 1, default, 1f); + return false; + } + } } diff --git a/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs b/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs index f2bfffc8ef..039532b093 100644 --- a/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs +++ b/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs @@ -1,6 +1,8 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables.LivingFire; using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -9,37 +11,87 @@ using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.LivingFire { - public class LivingGodSlayerFireBlockTile : ModTile - { - public override void SetDefaults() - { - Main.tileLighted[Type] = true; - soundType = SoundID.Dig; - drop = ModContent.ItemType(); - AddMapEntry(new Color(186, 85, 211)); - animationFrameHeight = 90; - TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.EmptyTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.EmptyTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.EmptyTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.EmptyTile, TileObjectData.newTile.Width, 0); - } + public class LivingGodSlayerFireBlockTile : ModTile + { + public override void SetDefaults() + { + Main.tileLighted[Type] = true; + soundType = SoundID.Dig; + drop = ModContent.ItemType(); + AddMapEntry(new Color(186, 85, 211)); + animationFrameHeight = 90; + Main.tileSolid[Type] = false; + Main.tileNoAttach[Type] = false; + Main.tileFrameImportant[Type] = false; + TileObjectData.newTile.Width = 1; + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.HookCheck = new PlacementHook(CanPlaceAlter, -1, 0, true ); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); - public override void AnimateTile(ref int frame, ref int frameCounter) - { + TileObjectData.addTile(Type); + } + + public int CanPlaceAlter(int i, int j, int type, int style, int direction) => 1; + + public static int AfterPlacement(int i, int j, int type, int style, int direction) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileRange(Main.myPlayer, i, j, 1, 1); + } + return 1; + } + + public override bool CanPlace(int i, int j) + { + List> around = new List> + { + new List() {i, j-1 }, + new List() {i-1, j }, + new List() {i+1, j }, + new List() {i, j+1 } + }; + //if (Main.tile[i, j]) || tile.type == Type + + //return true; //temporary for testing purposes + + if (Main.tile[i, j].wall != WallID.None) + { + return true; + } + + for (int k = 0; k < around.Count; ++k) + { + Tile tile = Main.tile[around[k][0], around[k][1]]; + if (tile.active() && (Main.tileSolid[tile.type] || CalamityMod.livingFireBlockList.Contains(tile.type))) + { + return true; + } + } + return false; + } + + public override void AnimateTile(ref int frame, ref int frameCounter) + { frame = Main.tileFrame[TileID.LivingFire]; - } + } - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { r = 1f; g = 0f; b = 1f; - } + } - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 1, default, 1f); - return false; - } - } + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 1, default, 1f); + return false; + } + } } diff --git a/Tiles/LivingFire/LivingHolyFireBlockTile.cs b/Tiles/LivingFire/LivingHolyFireBlockTile.cs index 0e593e3cff..6d334a5e41 100644 --- a/Tiles/LivingFire/LivingHolyFireBlockTile.cs +++ b/Tiles/LivingFire/LivingHolyFireBlockTile.cs @@ -1,6 +1,8 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables.LivingFire; using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; using Terraria; using Terraria.DataStructures; using Terraria.Enums; @@ -9,38 +11,87 @@ using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.LivingFire { - public class LivingHolyFireBlockTile : ModTile - { - public override void SetDefaults() - { - Main.tileLighted[Type] = true; - soundType = SoundID.Dig; - drop = ModContent.ItemType(); - AddMapEntry(new Color(255, 215, 0)); - animationFrameHeight = 90; - TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.SolidBottom | AnchorType.Tree | AnchorType.AlternateTile | AnchorType.EmptyTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.SolidBottom | AnchorType.Tree | AnchorType.AlternateTile | AnchorType.EmptyTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.SolidBottom | AnchorType.Tree | AnchorType.AlternateTile | AnchorType.EmptyTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide | AnchorType.SolidBottom | AnchorType.Tree | AnchorType.AlternateTile | AnchorType.EmptyTile, TileObjectData.newTile.Width, 0); - TileObjectData.newTile.UsesCustomCanPlace = false; - } + public class LivingHolyFireBlockTile : ModTile + { + public override void SetDefaults() + { + Main.tileLighted[Type] = true; + soundType = SoundID.Dig; + drop = ModContent.ItemType(); + AddMapEntry(new Color(255, 215, 0)); + animationFrameHeight = 90; + Main.tileSolid[Type] = false; + Main.tileNoAttach[Type] = false; + Main.tileFrameImportant[Type] = false; + TileObjectData.newTile.Width = 1; + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.CoordinateHeights = new int[] { 16 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.HookCheck = new PlacementHook(CanPlaceAlter, -1, 0, true ); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(AfterPlacement, -1, 0, false); - public override void AnimateTile(ref int frame, ref int frameCounter) - { + TileObjectData.addTile(Type); + } + + public int CanPlaceAlter(int i, int j, int type, int style, int direction) => 1; + + public static int AfterPlacement(int i, int j, int type, int style, int direction) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileRange(Main.myPlayer, i, j, 1, 1); + } + return 1; + } + + public override bool CanPlace(int i, int j) + { + List> around = new List> + { + new List() {i, j-1 }, + new List() {i-1, j }, + new List() {i+1, j }, + new List() {i, j+1 } + }; + //if (Main.tile[i, j]) || tile.type == Type + + //return true; //temporary for testing purposes + + if (Main.tile[i, j].wall != WallID.None) + { + return true; + } + + for (int k = 0; k < around.Count; ++k) + { + Tile tile = Main.tile[around[k][0], around[k][1]]; + if (tile.active() && (Main.tileSolid[tile.type] || CalamityMod.livingFireBlockList.Contains(tile.type))) + { + return true; + } + } + return false; + } + + public override void AnimateTile(ref int frame, ref int frameCounter) + { frame = Main.tileFrame[TileID.LivingFire]; - } + } - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { r = 1f; g = 1f; b = 0f; - } + } - public override bool CreateDust(int i, int j, ref int type) - { - Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.ProfanedFire, 0f, 0f, 1, default, 1f); - return false; - } - } + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, (int)CalamityDusts.ProfanedFire, 0f, 0f, 1, default, 1f); + return false; + } + } } diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 6d0668e0c0..0a4d0b339c 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -2,7 +2,10 @@ using CalamityMod.CalPlayer; using CalamityMod.Items; using CalamityMod.Items.Tools.ClimateChange; using CalamityMod.NPCs; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.Providence; using CalamityMod.Projectiles; +using CalamityMod.Projectiles.Summon; using CalamityMod.Tiles; using CalamityMod.Tiles.Abyss; using CalamityMod.Tiles.Astral; @@ -239,6 +242,52 @@ namespace CalamityMod damage = 0D; return true; } + + /// + /// Check if an NPC is organic + /// + /// The NPC attacked. + /// Whether or not the NPC is organic. + public static bool Organic(this NPC target) + { + if ((target.HitSound != SoundID.NPCHit4 && target.HitSound != SoundID.NPCHit41 && target.HitSound != SoundID.NPCHit2 && + target.HitSound != SoundID.NPCHit5 && target.HitSound != SoundID.NPCHit11 && target.HitSound != SoundID.NPCHit30 && + target.HitSound != SoundID.NPCHit34 && target.HitSound != SoundID.NPCHit36 && target.HitSound != SoundID.NPCHit42 && + target.HitSound != SoundID.NPCHit49 && target.HitSound != SoundID.NPCHit52 && target.HitSound != SoundID.NPCHit53 && + target.HitSound != SoundID.NPCHit54 && target.HitSound != null) || target.type == ModContent.NPCType() || + target.type == ModContent.NPCType()) + { + return true; + } + return false; + } + + /// + /// Check if an NPC is inorganic + /// + /// The NPC attacked. + /// Whether or not the NPC is inorganic. + public static bool Inorganic(this NPC target) + { + if (target.HitSound != SoundID.NPCHit1 && target.HitSound != SoundID.NPCHit6 && target.HitSound != SoundID.NPCHit7 && + target.HitSound != SoundID.NPCHit8 && target.HitSound != SoundID.NPCHit9 && target.HitSound != SoundID.NPCHit12 && + target.HitSound != SoundID.NPCHit13 && target.HitSound != SoundID.NPCHit14 && target.HitSound != SoundID.NPCHit18 && + target.HitSound != SoundID.NPCHit19 && target.HitSound != SoundID.NPCHit20 && target.HitSound != SoundID.NPCHit21 && + target.HitSound != SoundID.NPCHit22 && target.HitSound != SoundID.NPCHit23 && target.HitSound != SoundID.NPCHit24 && + target.HitSound != SoundID.NPCHit25 && target.HitSound != SoundID.NPCHit26 && target.HitSound != SoundID.NPCHit27 && + target.HitSound != SoundID.NPCHit28 && target.HitSound != SoundID.NPCHit29 && target.HitSound != SoundID.NPCHit31 && + target.HitSound != SoundID.NPCHit32 && target.HitSound != SoundID.NPCHit33 && target.HitSound != SoundID.NPCHit35 && + target.HitSound != SoundID.NPCHit37 && target.HitSound != SoundID.NPCHit38 && target.HitSound != SoundID.NPCHit40 && + target.HitSound != SoundID.NPCHit43 && target.HitSound != SoundID.NPCHit44 && target.HitSound != SoundID.NPCHit45 && + target.HitSound != SoundID.NPCHit46 && target.HitSound != SoundID.NPCHit47 && target.HitSound != SoundID.NPCHit48 && + target.HitSound != SoundID.NPCHit50 && target.HitSound != SoundID.NPCHit51 && target.HitSound != SoundID.NPCHit55 && + target.HitSound != SoundID.NPCHit56 && target.HitSound != SoundID.NPCHit57 && target.type != ModContent.NPCType() && + target.type != ModContent.NPCType() && target.type != ModContent.NPCType()) + { + return true; + } + return false; + } #endregion #region Item Utilities @@ -676,6 +725,414 @@ namespace CalamityMod } return newDamage; } + + public static void MinionAntiClump(this Projectile projectile, float pushForce = 0.05f) + { + for (int k = 0; k < Main.maxProjectiles; k++) + { + Projectile otherProj = Main.projectile[k]; + // Short circuits to make the loop as fast as possible + if (!otherProj.active || otherProj.owner != projectile.owner || !otherProj.minion || k == projectile.whoAmI) + continue; + + // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away. + bool sameProjType = otherProj.type == projectile.type; + float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y); + if (sameProjType && taxicabDist < projectile.width) + { + if (projectile.position.X < otherProj.position.X) + projectile.velocity.X -= pushForce; + else + projectile.velocity.X += pushForce; + + if (projectile.position.Y < otherProj.position.Y) + projectile.velocity.Y -= pushForce; + else + projectile.velocity.Y += pushForce; + } + } + } + + public static void ChargingMinionAI(this Projectile projectile, float range, float maxPlayerDist, float extraMaxPlayerDist, float safeDist, int initialUpdates, float chargeDelayTime, float goToSpeed, float goBackSpeed, float chargeCounterMax, float chargeSpeed, bool tileVision, bool ignoreTilesWhenCharging) + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + + //Anti sticky movement to prevent stacking + projectile.MinionAntiClump(); + + //Breather time between charges as like a reset + bool chargeDelay = false; + if (projectile.ai[0] == 2f) + { + projectile.ai[1] += 1f; + projectile.extraUpdates = initialUpdates + (projectile.type == ModContent.ProjectileType() ? 2 : 1); + if (projectile.ai[1] > chargeDelayTime) + { + projectile.ai[1] = 1f; + projectile.ai[0] = 0f; + projectile.extraUpdates = initialUpdates; + projectile.numUpdates = 0; + projectile.netUpdate = true; + } + else + { + chargeDelay = true; + } + } + if (chargeDelay) + { + return; + } + + //Find a target + float maxDist = range; + Vector2 targetVec = projectile.position; + bool foundTarget = false; + Vector2 half = new Vector2(0.5f); + bool isButterfly = projectile.type == ModContent.ProjectileType(); + //Prioritize the targeted enemy if possible + if (player.HasMinionAttackTargetNPC) + { + NPC npc = Main.npc[player.MinionAttackTargetNPC]; + bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly; + if (npc.CanBeChasedBy(projectile, false) || fishronCheck) + { + //Check the size of the target to make it easier to hit fat targets like Levi + Vector2 sizeCheck = npc.position + npc.Size * half; + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + //Some minions will ignore tiles when choosing a target like Ice Claspers, others will not + bool canHit = true; + if (!tileVision) + canHit = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); + if (!foundTarget && targetDist < maxDist && canHit) + { + maxDist = targetDist; + targetVec = sizeCheck; + foundTarget = true; + } + } + } + //If no npc is specifically targetted, check through the entire array + else + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly; + if (npc.CanBeChasedBy(projectile, false) || fishronCheck) + { + Vector2 sizeCheck = npc.position + npc.Size * half; + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + bool canHit = true; + if (!tileVision) + canHit = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); + if (!foundTarget && targetDist < maxDist && canHit) + { + maxDist = targetDist; + targetVec = sizeCheck; + foundTarget = true; + } + } + } + } + + //If the player is too far, return to the player. Range is increased while attacking something. + float distBeforeForcedReturn = maxPlayerDist; + if (foundTarget) + { + distBeforeForcedReturn = extraMaxPlayerDist; + } + if (Vector2.Distance(player.Center, projectile.Center) > distBeforeForcedReturn) + { + projectile.ai[0] = 1f; + projectile.netUpdate = true; + } + + //Go to the target if you found one + if (foundTarget && projectile.ai[0] == 0f) + { + //Some minions don't ignore tiles while charging like brittle stars + projectile.tileCollide = !ignoreTilesWhenCharging; + Vector2 targetSpot = targetVec - projectile.Center; + float targetDist = targetSpot.Length(); + targetSpot.Normalize(); + //Tries to get the minion in the sweet spot of 200 pixels away but the minion also charges so idk what good it does + if (targetDist > 200f) + { + float speed = goToSpeed; //8 + targetSpot *= speed; + projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; + } + else + { + float speed = -goBackSpeed; //-4 + targetSpot *= speed; + projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; //41 + } + } + + //Movement for idle or returning to the player + else + { + //Ignore tiles so they don't get stuck everywhere like Optic Staff + projectile.tileCollide = false; + + bool returningToPlayer = false; + if (!returningToPlayer) + { + returningToPlayer = projectile.ai[0] == 1f; + } + + //Player distance calculations + Vector2 playerVec = player.Center - projectile.Center + new Vector2(0f, -60f); + float playerDist = playerVec.Length(); + + //If the minion is actively returning, move faster + float playerHomeSpeed = 6f; + if (returningToPlayer) + { + playerHomeSpeed = 15f; + } + //Move somewhat faster if the player is kinda far~ish + if (playerDist > 200f && playerHomeSpeed < 8f) + { + playerHomeSpeed = 8f; + } + //Return to normal if close enough to the player + if (playerDist < safeDist && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + //Teleport to the player if abnormally far + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - (float)(projectile.width / 2); + projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); + projectile.netUpdate = true; + } + //If more than 70 pixels away, move toward the player + if (playerDist > 70f) + { + playerVec.Normalize(); + playerVec *= playerHomeSpeed; + projectile.velocity = (projectile.velocity * 40f + playerVec) / 41f; + } + //Minions never stay still + else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f) + { + projectile.velocity.X = -0.15f; + projectile.velocity.Y = -0.05f; + } + } + + //Increment attack counter randomly + if (projectile.ai[1] > 0f) + { + projectile.ai[1] += (float)Main.rand.Next(1, 4); + } + //If high enough, prepare to attack + if (projectile.ai[1] > chargeCounterMax) + { + projectile.ai[1] = 0f; + projectile.netUpdate = true; + } + + //Charge at an enemy if not on cooldown + if (projectile.ai[0] == 0f) + { + if (projectile.ai[1] == 0f && foundTarget && maxDist < 500f) + { + projectile.ai[1] += 1f; + if (Main.myPlayer == projectile.owner) + { + projectile.ai[0] = 2f; + Vector2 targetPos = targetVec - projectile.Center; + targetPos.Normalize(); + projectile.velocity = targetPos * chargeSpeed; //8 + projectile.netUpdate = true; + } + } + } + } + + public static void FloatingPetAI(this Projectile projectile, bool faceRight, float tiltFloat, bool lightPet = false) + { + Player player = Main.player[projectile.owner]; + + //anti sticking movement as a failsafe + float SAImovement = 0.05f; + for (int k = 0; k < Main.maxProjectiles; k++) + { + Projectile otherProj = Main.projectile[k]; + // Short circuits to make the loop as fast as possible + if (!otherProj.active || otherProj.owner != projectile.owner || !Main.projPet[otherProj.type] || k == projectile.whoAmI) + continue; + + // If the other projectile is indeed another pet owned by the same player and they're too close, nudge them away. + bool isPet = Main.projPet[otherProj.type]; + float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y); + if (isPet && taxicabDist < projectile.width) + { + if (projectile.position.X < otherProj.position.X) + projectile.velocity.X -= SAImovement; + else + projectile.velocity.X += SAImovement; + + if (projectile.position.Y < otherProj.position.Y) + projectile.velocity.Y -= SAImovement; + else + projectile.velocity.Y += SAImovement; + } + } + + float passiveMvtFloat = 0.5f; + projectile.tileCollide = false; + float range = 100f; + Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y); + float xDist = player.Center.X - projPos.X; + float yDist = player.Center.Y - projPos.Y; + yDist += Main.rand.NextFloat(-10, 20); + xDist += Main.rand.NextFloat(-10, 20); + //Light pets lead the player, normal pets trail the player + xDist += 60f * (lightPet ? (float)player.direction : -(float)player.direction); + yDist -= 60f; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); + float returnSpeed = 18f; + + //If player is close enough, resume normal + if (playerDist < range && player.velocity.Y == 0f && + projectile.position.Y + projectile.height <= player.position.Y + player.height && + !Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + if (projectile.velocity.Y < -6f) + { + projectile.velocity.Y = -6f; + } + } + + //Teleport to player if too far + if (playerDist > 2000f) + { + projectile.position.X = player.Center.X - projectile.width / 2; + projectile.position.Y = player.Center.Y - projectile.height / 2; + projectile.netUpdate = true; + } + + if (playerDist < 50f) + { + if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) + { + projectile.velocity *= 0.99f; + } + passiveMvtFloat = 0.01f; + } + else + { + if (playerDist < 100f) + { + passiveMvtFloat = 0.1f; + } + if (playerDist > 300f) + { + passiveMvtFloat = 1f; + } + playerDist = returnSpeed / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; + } + if (projectile.velocity.X < playerVector.X) + { + projectile.velocity.X += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.X < 0f) + { + projectile.velocity.X += passiveMvtFloat; + } + } + if (projectile.velocity.X > playerVector.X) + { + projectile.velocity.X -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.X > 0f) + { + projectile.velocity.X -= passiveMvtFloat; + } + } + if (projectile.velocity.Y < playerVector.Y) + { + projectile.velocity.Y += passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.Y < 0f) + { + projectile.velocity.Y += passiveMvtFloat * 2f; + } + } + if (projectile.velocity.Y > playerVector.Y) + { + projectile.velocity.Y -= passiveMvtFloat; + if (passiveMvtFloat > 0.05f && projectile.velocity.Y > 0f) + { + projectile.velocity.Y -= passiveMvtFloat * 2f; + } + } + if (projectile.velocity.X >= 0.25f) + { + projectile.direction = faceRight ? 1 : -1; + } + else if (projectile.velocity.X < -0.25f) + { + projectile.direction = faceRight ? -1 : 1; + } + //Tilting and change directions + projectile.spriteDirection = projectile.direction; + projectile.rotation = projectile.velocity.X * tiltFloat; + } + + public static void HealingProjectile(this Projectile projectile, int healing, int playerToHeal, float homingVelocity, float N, bool autoHomes = true, int timeCheck = 120) + { + int target = playerToHeal; + Player player = Main.player[target]; + float homingSpeed = homingVelocity; + if (player.lifeMagnet) + homingSpeed *= 1.5f; + + Vector2 projPos = new Vector2(projectile.Center.X, projectile.Center.Y); + float xDist = player.Center.X - projPos.X; + float yDist = player.Center.Y - projPos.Y; + Vector2 playerVector = new Vector2(xDist, yDist); + float playerDist = playerVector.Length(); + if (playerDist < 50f && projectile.position.X < player.position.X + player.width && projectile.position.X + projectile.width > player.position.X && projectile.position.Y < player.position.Y + player.height && projectile.position.Y + projectile.height > player.position.Y) + { + if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech) + { + int healAmt = healing; + player.HealEffect(healAmt, false); + player.statLife += healAmt; + if (player.statLife > player.statLifeMax2) + { + player.statLife = player.statLifeMax2; + } + NetMessage.SendData(MessageID.SpiritHeal, -1, -1, null, target, healAmt, 0f, 0f, 0, 0, 0); + } + projectile.Kill(); + } + if (autoHomes) + { + playerDist = homingSpeed / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; + projectile.velocity.X = (projectile.velocity.X * N + playerVector.X) / (N + 1f); + projectile.velocity.Y = (projectile.velocity.Y * N + playerVector.Y) / (N + 1f); + } + else if (player.lifeMagnet && projectile.timeLeft < timeCheck) + { + playerDist = homingVelocity / playerDist; + playerVector.X *= playerDist; + playerVector.Y *= playerDist; + projectile.velocity.X = (projectile.velocity.X * N + playerVector.X) / (N + 1f); + projectile.velocity.Y = (projectile.velocity.Y * N + playerVector.Y) / (N + 1f); + } + } #endregion #region Tile Utilities diff --git a/World/Abyss.cs b/World/Abyss.cs index af4dca1ef6..742014926b 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -71,6 +71,7 @@ namespace CalamityMod.World GenerateUpperSea(); CreateWater(); GenerateHardenedSandstone(); + RemoveStupidTilesAboveSea(); SettleWater(); // The island Y spawn position calculations are relative to water. Settling the water before doing these calculations is ideal. GenerateIslands(); GenerateVentsAndFossils(); @@ -325,13 +326,6 @@ namespace CalamityMod.World } } } - else if (WorldGen.genRand.NextBool(10)) - { - for (int i = 0; i < 20; i++) - { - TileLoader.RandomUpdate(trueX, y, Main.tile[trueX, y].type); - } - } } } } @@ -742,7 +736,7 @@ namespace CalamityMod.World SulphSeaTiles.Contains(CalamityUtils.ParanoidTileRetrieval(x, y + 1).type) && CalamityUtils.ParanoidTileRetrieval(x, y + 1).active()) { - chest = WorldGenerationMethods.AddChestWithLoot(x, y, (ushort)ModContent.TileType(), tileStyle: 1); + chest = WorldGenerationMethods.AddChestWithLoot(x, y, (ushort)ModContent.TileType()); } } } @@ -757,9 +751,30 @@ namespace CalamityMod.World } #endregion + #region Removal of stupid Tiles above the Sea + public static void RemoveStupidTilesAboveSea() + { + for (int x = 0; x < BiomeWidth; x++) + { + int trueX = CalamityWorld.abyssSide ? x : Main.maxTilesX - x; + for (int y = YStart - 100; y < YStart + 60; y++) + { + if (YStartWhitelist.Contains(CalamityUtils.ParanoidTileRetrieval(trueX, y).type)) + { + if (Main.tile[trueX, y] == null) + Main.tile[trueX, y] = new Tile(); + Main.tile[trueX, y].active(false); + } + } + } + } + #endregion + #region Misc Functions public static List YStartWhitelist = new List() { + TileID.Stone, + TileID.Dirt, TileID.Sand, TileID.Ebonsand, TileID.Crimsand, @@ -776,12 +791,26 @@ namespace CalamityMod.World TileID.Tungsten, TileID.Crimstone, TileID.Ebonstone, + TileID.HardenedSand, + TileID.CorruptHardenedSand, + TileID.CrimsonHardenedSand, + TileID.Coral, + TileID.BeachPiles, + TileID.Plants, + TileID.Plants2, + TileID.SmallPiles, + TileID.LargePiles, + TileID.LargePiles2, + TileID.Trees, + TileID.Vines, + TileID.CrimsonVines, + TileID.Containers, TileID.JungleGrass // Yes, this can happen on rare occasion }; public static void DetermineYStart() { int maxHeight = 0; - for (int i = 0; i < BiomeWidth; i++) + for (int i = 0; i < BiomeWidth - 18; i++) { int xCheck = CalamityWorld.abyssSide ? BiomeWidth - i : diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 53efbf3fab..a98ff26869 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -111,6 +111,8 @@ namespace CalamityMod.World public static bool forcedRainAlready = false; public static bool forcedDownpourWithTear = false; public static int forceRainTimer = 0; + public static int timeSinceAcidRainKill = 0; + public static int timeSinceAcidStarted = 0; public static float AcidRainCompletionRatio { get @@ -967,6 +969,17 @@ namespace CalamityMod.World if (rainingAcid) { + timeSinceAcidRainKill++; + timeSinceAcidStarted++; + + // If enough time has passed, and no enemy has been killed, end the invasion early. + // The player almost certainly does not want to deal with it. + if (timeSinceAcidRainKill >= AcidRainEvent.InvasionNoKillPersistTime) + { + acidRainPoints = 0; + triedToSummonOldDuke = false; + AcidRainEvent.UpdateInvasion(false); + } if (!startAcidicDownpour) { int sulphSeaWidth = Abyss.BiomeWidth; @@ -984,6 +997,8 @@ namespace CalamityMod.World (player2.Center.X >= (Main.maxTilesX - (sulphSeaWidth + 60f)) * 16f && !abyssSide)) && player2.Calamity().ZoneSulphur) { + // Makes rain pour at its maximum intensity (but only after an idiot meanders into the Sulphurous Sea) + // You'll never catch me, Fabs, Not when I shift into MAXIMUM OVERDRIVE!! startAcidicDownpour = true; CalamityMod.UpdateServerBoolean(); break; @@ -992,22 +1007,37 @@ namespace CalamityMod.World } } - // Makes rain pour at its maximum intensity (but only after an idiot meanders into the Sulphurous Sea) - // You'll never catch me, Fabs, Not when I shift into MAXIMUM OVERDRIVE!! - if ((startAcidicDownpour || forcedDownpourWithTear) && !NPC.AnyNPCs(ModContent.NPCType())) + // Stop the rain if the Old Duke is present for visibility during the fight. + if (Main.raining && NPC.AnyNPCs(ModContent.NPCType())) { - Main.raining = true; - Main.cloudBGActive = 1f; - Main.numCloudsTemp = Main.cloudLimit; - Main.numClouds = Main.numCloudsTemp; - Main.windSpeedTemp = 0.72f; - Main.windSpeedSet = Main.windSpeedTemp; - Main.weatherCounter = 600; - Main.maxRaining = 0.89f; - } + Main.raining = false; + CalamityMod.UpdateServerBoolean(); + } + + // If the rain stops for whatever reason, end the invasion. + // This is primarily done for compatibility, so that if another mod wants to manipulate the weather, + // they can without having to deal with endless rain. + if (!Main.raining && !NPC.AnyNPCs(ModContent.NPCType()) && timeSinceAcidStarted > 20) + { + acidRainPoints = 0; + triedToSummonOldDuke = false; + AcidRainEvent.UpdateInvasion(false); + } + else if (timeSinceAcidStarted < 20) + { + Main.raining = true; + Main.cloudBGActive = 1f; + Main.numCloudsTemp = Main.cloudLimit; + Main.numClouds = Main.numCloudsTemp; + Main.windSpeedTemp = 0.72f; + Main.windSpeedSet = Main.windSpeedTemp; + Main.weatherCounter = 60 * 60 * 10; // 10 minutes of rain. Remember, once the rain goes away, so does the invasion. + Main.rainTime = Main.weatherCounter; + Main.maxRaining = 0.89f; + } // Summon Old Duke tornado post-Polter as needed - if (downedPolterghast && acidRainPoints == 2) + if (downedPolterghast && acidRainPoints == 1) { if (!NPC.AnyNPCs(ModContent.NPCType()) && CalamityUtils.CountProjectiles(ModContent.ProjectileType()) <= 0) @@ -1033,7 +1063,9 @@ namespace CalamityMod.World } else { - startAcidicDownpour = false; + if (timeSinceAcidStarted != 0) + timeSinceAcidStarted = 0; + startAcidicDownpour = false; } // Lumenyl crystal, tenebris spread and sea prism crystal spawn rates diff --git a/World/WorldGenerationMethods.cs b/World/WorldGenerationMethods.cs index d0c7a002f7..d4de0fd404 100644 --- a/World/WorldGenerationMethods.cs +++ b/World/WorldGenerationMethods.cs @@ -139,7 +139,7 @@ namespace CalamityMod.World } PutItemInChest(ref chest, ItemID.GoldCoin, goldCoins); } - else if (type == ModContent.TileType()) + else if (type == ModContent.TileType()) { // 15-29 torches (in accordence with vanilla) PutItemInChest(ref chest, ItemID.Torch, 15, 29);