From 29770110f1d041fc31926f937713bf6aba400bd8 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 10:47:45 -0400 Subject: [PATCH 01/53] cosmic shiv nerf --- Projectiles/Melee/CosmicShivBall.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Projectiles/Melee/CosmicShivBall.cs b/Projectiles/Melee/CosmicShivBall.cs index 09fca156bb..2b95193726 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); From b4cb8e4000c79c64c06835b2b3e497b7c108ee5a Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 10:57:27 -0400 Subject: [PATCH 02/53] buffed butcher, moved it later in progression, nerfed clamor rifle and polaris parrotfish --- .../AstralCatches/PolarisParrotfish.cs | 8 +- Items/Weapons/Ranged/Butcher.cs | 103 ++++++++---------- Items/Weapons/Ranged/ClamorRifle.cs | 69 ++++++------ Projectiles/Ranged/ButcherGun.cs | 18 +-- 4 files changed, 93 insertions(+), 105 deletions(-) diff --git a/Items/Fishing/AstralCatches/PolarisParrotfish.cs b/Items/Fishing/AstralCatches/PolarisParrotfish.cs index e44f282be1..b46a3996b3 100644 --- a/Items/Fishing/AstralCatches/PolarisParrotfish.cs +++ b/Items/Fishing/AstralCatches/PolarisParrotfish.cs @@ -19,12 +19,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 = 5; item.noMelee = true; item.knockBack = 2.25f; @@ -46,7 +46,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/Weapons/Ranged/Butcher.cs b/Items/Weapons/Ranged/Butcher.cs index 1827f2bd1d..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 = 5; - 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 c014be74a2..2495212021 100644 --- a/Items/Weapons/Ranged/ClamorRifle.cs +++ b/Items/Weapons/Ranged/ClamorRifle.cs @@ -4,43 +4,40 @@ using Terraria; using Terraria.ModLoader; 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 = 5; - 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/Projectiles/Ranged/ButcherGun.cs b/Projectiles/Ranged/ButcherGun.cs index a52885e739..8c103ce8f3 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; From 0080d869115856a6f6c895a43e260ebe5166644e Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 10:58:51 -0400 Subject: [PATCH 03/53] buffed apoctolith --- Items/Weapons/Rogue/Apoctolith.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; From 36d4a56ddaaadc13993f365bc772f3ccf26887c2 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 11:00:43 -0400 Subject: [PATCH 04/53] nerfed hematemesis --- Items/Weapons/Magic/Hematemesis.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Items/Weapons/Magic/Hematemesis.cs b/Items/Weapons/Magic/Hematemesis.cs index d9bebc5370..4c50c511d9 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 = 5; 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; } From 7d47ee7b220fec886e8637f5b750dc8bf5da9e9a Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 11:02:53 -0400 Subject: [PATCH 05/53] plague staff i frame nerf --- Projectiles/Magic/PlagueFang.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Projectiles/Magic/PlagueFang.cs b/Projectiles/Magic/PlagueFang.cs index 901e4eb0f2..f32743a699 100644 --- a/Projectiles/Magic/PlagueFang.cs +++ b/Projectiles/Magic/PlagueFang.cs @@ -21,6 +21,8 @@ namespace CalamityMod.Projectiles.Magic projectile.alpha = 255; projectile.penetrate = 9; projectile.timeLeft = 300; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 5; } public override void AI() @@ -78,7 +80,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; } } } From fca8dc5019d9916411e665e18fac9c4bfad601b0 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 11:04:12 -0400 Subject: [PATCH 06/53] slightly buffed laser machinegun --- Items/CalamityGlobalItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 97b52f456c..7855b0114d 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -130,7 +130,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); From 2bb3d247fff9cab427c79687b87256df2399e475 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 11:05:41 -0400 Subject: [PATCH 07/53] buffed astral scythe --- Items/Weapons/Melee/AstralScythe.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Items/Weapons/Melee/AstralScythe.cs b/Items/Weapons/Melee/AstralScythe.cs index 90852c6093..3b9ebd53ce 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; } From ffb307a141bd2e01e14a0dce2827362b36904101 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 11:06:26 -0400 Subject: [PATCH 08/53] buffed brimblade stealth strike --- Items/Weapons/Rogue/Brimblade.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Rogue/Brimblade.cs b/Items/Weapons/Rogue/Brimblade.cs index 3c0f1faf82..925ede4fed 100644 --- a/Items/Weapons/Rogue/Brimblade.cs +++ b/Items/Weapons/Rogue/Brimblade.cs @@ -48,7 +48,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; From 682af60b8868f0b9c012f79adbd2045da1137015 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 11:11:25 -0400 Subject: [PATCH 09/53] nerfed storm spray and waywasher --- Items/Weapons/Magic/StormSpray.cs | 2 +- Items/Weapons/Magic/Waywasher.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Items/Weapons/Magic/StormSpray.cs b/Items/Weapons/Magic/StormSpray.cs index 1d39ed22ff..b6684f7faa 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/Waywasher.cs b/Items/Weapons/Magic/Waywasher.cs index 6ff0f3baab..4dcf8ded4b 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; From 7ad94d80b120181ebc6a34926048b15ece73eafd Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 11:12:06 -0400 Subject: [PATCH 10/53] buffed brittle & aquatic star charge speed --- Projectiles/Summon/AquaticStarMinion.cs | 2 +- Projectiles/Summon/BrittleStarMinion.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Projectiles/Summon/AquaticStarMinion.cs b/Projectiles/Summon/AquaticStarMinion.cs index 67f2fb93cc..9a03d452d6 100644 --- a/Projectiles/Summon/AquaticStarMinion.cs +++ b/Projectiles/Summon/AquaticStarMinion.cs @@ -65,7 +65,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); + CalamityGlobalProjectile.ChargingMinionAI(projectile, 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/BrittleStarMinion.cs b/Projectiles/Summon/BrittleStarMinion.cs index c8c761d021..ef5959d9dd 100644 --- a/Projectiles/Summon/BrittleStarMinion.cs +++ b/Projectiles/Summon/BrittleStarMinion.cs @@ -65,7 +65,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); + CalamityGlobalProjectile.ChargingMinionAI(projectile, 600f, 800f, 1200f, 150f, 0, 40f, 8f, -4f, 40f, 9.5f, false, false); } public override bool OnTileCollide(Vector2 oldVelocity) => false; From 92225e60119e264c5d5aa8a6641a19c5a78b2092 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 11:14:39 -0400 Subject: [PATCH 11/53] nerf to halley's --- Items/Weapons/Ranged/HalleysInferno.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Items/Weapons/Ranged/HalleysInferno.cs b/Items/Weapons/Ranged/HalleysInferno.cs index 9520c9fdc6..a4e2e46752 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() { From 39db984a7d4329beb14d3a79f227226c499ce261 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 11:16:20 -0400 Subject: [PATCH 12/53] buffed dodu's handcannon --- Items/Weapons/Ranged/DodusHandcannon.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Ranged/DodusHandcannon.cs b/Items/Weapons/Ranged/DodusHandcannon.cs index 439445107c..04de349700 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; From db2896c7f5a321bac6cad8b1274b675140853083 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 11:18:29 -0400 Subject: [PATCH 13/53] relic of ruin nerf --- Items/Weapons/Magic/RelicofRuin.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Items/Weapons/Magic/RelicofRuin.cs b/Items/Weapons/Magic/RelicofRuin.cs index a6f315c111..62d827ae77 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.01 * 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); From 272de98be35ce5654a029f4c98af6b9fed0b8c08 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 11:33:24 -0400 Subject: [PATCH 14/53] error fixes --- Items/Fishing/AstralCatches/PolarisParrotfish.cs | 3 ++- Items/Weapons/Magic/RelicofRuin.cs | 2 +- Items/Weapons/Ranged/ClamorRifle.cs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Items/Fishing/AstralCatches/PolarisParrotfish.cs b/Items/Fishing/AstralCatches/PolarisParrotfish.cs index b46a3996b3..47c23f02f7 100644 --- a/Items/Fishing/AstralCatches/PolarisParrotfish.cs +++ b/Items/Fishing/AstralCatches/PolarisParrotfish.cs @@ -2,6 +2,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Fishing.AstralCatches @@ -25,7 +26,7 @@ namespace CalamityMod.Items.Fishing.AstralCatches item.height = 34; item.useTime = 21; item.useAnimation = 21; - item.useStyle = 5; + item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 2.25f; item.value = Item.buyPrice(0, 36, 0, 0); diff --git a/Items/Weapons/Magic/RelicofRuin.cs b/Items/Weapons/Magic/RelicofRuin.cs index 62d827ae77..d7386c80c4 100644 --- a/Items/Weapons/Magic/RelicofRuin.cs +++ b/Items/Weapons/Magic/RelicofRuin.cs @@ -37,7 +37,7 @@ 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.01 * MathHelper.PiOver2; + float spread = 22.5f * 0.01f * MathHelper.PiOver2; double startAngle = Math.Atan2(speedX, speedY) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; diff --git a/Items/Weapons/Ranged/ClamorRifle.cs b/Items/Weapons/Ranged/ClamorRifle.cs index 2495212021..f936fd41f1 100644 --- a/Items/Weapons/Ranged/ClamorRifle.cs +++ b/Items/Weapons/Ranged/ClamorRifle.cs @@ -1,6 +1,7 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { From 1f32bbc00c7ac356dd6883dac5982a4f2599692e Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 14:01:01 -0400 Subject: [PATCH 15/53] fixed accessory reforge memes --- Items/CalamityGlobalItem.cs | 6 ++++++ Items/Weapons/Rogue/RogueWeapon.cs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 7855b0114d..250089c1c5 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -82,6 +82,12 @@ namespace CalamityMod.Items myClone.StealthGenBonus = StealthGenBonus; return myClone; } + + public override bool NewPreReforge(Item item) + { + StealthGenBonus = 1f; + return true; + } #endregion #region SetDefaults 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(); From 05939c30101366dc8f23055d6f53f7796f4f2ddd Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 19:55:15 -0400 Subject: [PATCH 16/53] nerfed photo alt, gastric belcher, and fixed brimstone sword using the wrong explosion --- Items/Weapons/Ranged/Photoviscerator.cs | 2 +- Items/Weapons/Summon/GastricBelcherStaff.cs | 4 ++-- Projectiles/Melee/ProfanedSwordProj.cs | 2 +- Projectiles/Ranged/ExoLight.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Items/Weapons/Ranged/Photoviscerator.cs b/Items/Weapons/Ranged/Photoviscerator.cs index f01934d293..09bcc37c8e 100644 --- a/Items/Weapons/Ranged/Photoviscerator.cs +++ b/Items/Weapons/Ranged/Photoviscerator.cs @@ -68,7 +68,7 @@ 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 * 2.3), knockBack, player.whoAmI); } else { 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/Projectiles/Melee/ProfanedSwordProj.cs b/Projectiles/Melee/ProfanedSwordProj.cs index 8fc208f640..2563dbef25 100644 --- a/Projectiles/Melee/ProfanedSwordProj.cs +++ b/Projectiles/Melee/ProfanedSwordProj.cs @@ -68,7 +68,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/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() From 4518f0c2bfa83b6f6509c30df71d0e3039c67f9a Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 19:56:51 -0400 Subject: [PATCH 17/53] increased sandnado aggro range --- Projectiles/Summon/SandnadoMinion.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Projectiles/Summon/SandnadoMinion.cs b/Projectiles/Summon/SandnadoMinion.cs index 97a1517504..90bec14af3 100644 --- a/Projectiles/Summon/SandnadoMinion.cs +++ b/Projectiles/Summon/SandnadoMinion.cs @@ -103,7 +103,7 @@ namespace CalamityMod.Projectiles.Summon } } Vector2 vector = projectile.position; - float num10 = 900f; + float num10 = 1200f; bool flag = false; if (Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) { @@ -157,12 +157,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; From bd1d5a4abcafec9d976d8ed390c99cd20718320c Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 19:59:25 -0400 Subject: [PATCH 18/53] nerfed shellfish staff --- NPCs/CalamityGlobalNPC.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 0e545b50c3..b6f5f277aa 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -516,11 +516,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; } } From 6ea5f364664968a7bbba1d69a54dd34c627158b0 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 20:00:02 -0400 Subject: [PATCH 19/53] slight black hawk nerf --- Items/Weapons/Summon/BlackHawkRemote.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 695db6506ace97b6f6a5a35f58cf525cf2e3295e Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 20:29:40 -0400 Subject: [PATCH 20/53] fixed auric toilet being unplacable --- Tiles/Furniture/AuricToiletTile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From f38406f18886137117c55189c94dde41ca405681 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 20:47:23 -0400 Subject: [PATCH 21/53] fixed stupid scepter name --- Items/Weapons/Magic/ParasiticSceptor.cs | 70 ++++++++++++------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/Items/Weapons/Magic/ParasiticSceptor.cs b/Items/Weapons/Magic/ParasiticSceptor.cs index 9b48e1101c..b184d297b1 100644 --- a/Items/Weapons/Magic/ParasiticSceptor.cs +++ b/Items/Weapons/Magic/ParasiticSceptor.cs @@ -11,7 +11,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; } @@ -30,7 +30,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; } @@ -39,28 +39,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)) { @@ -74,21 +74,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; } } From 52ffc8cb19c022e3453837d17c0d6e9faa1459ea Mon Sep 17 00:00:00 2001 From: DominicKarma42 <51094361+DominicKarma@users.noreply.github.com> Date: Sat, 30 May 2020 20:00:16 -0500 Subject: [PATCH 22/53] Couple of sulph sea adjustments (see description) - Made the acid rain depend on whether the rain is active. - Made the acid rain go away after 4 minutes if no enemies are killed in that time period. - Prevented natural tiles from forming a clump above the sulph sea during worldgen - Cut a good amount of of lag from the sulph sea generation process. - Changed the 98% completion to 99% when Old Duke appears. --- CalamityMod.cs | 1 + Events/AcidRainEvent.cs | 12 +++-- Items/Tools/ClimateChange/TorrentialTear.cs | 14 +---- NPCs/CalamityGlobalNPCLoot.cs | 7 ++- World/Abyss.cs | 45 +++++++++++++--- World/CalamityWorld.cs | 60 ++++++++++++++++----- 6 files changed, 97 insertions(+), 42 deletions(-) diff --git a/CalamityMod.cs b/CalamityMod.cs index 5ef3fbafb4..f93d0441d5 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -3743,6 +3743,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 0b32c27cb6..58bdc882ab 100644 --- a/Events/AcidRainEvent.cs +++ b/Events/AcidRainEvent.cs @@ -35,6 +35,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. @@ -168,17 +170,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! } @@ -223,6 +224,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/Tools/ClimateChange/TorrentialTear.cs b/Items/Tools/ClimateChange/TorrentialTear.cs index 3f664889a9..8342d2ba68 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/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 3b773eccd8..a44ade281f 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -1623,16 +1623,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; @@ -1641,7 +1643,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. } } @@ -1654,6 +1656,7 @@ namespace CalamityMod.NPCs CalamityWorld.triedToSummonOldDuke = false; CalamityWorld.acidRainPoints = 0; } + CalamityWorld.timeSinceAcidRainKill = 0; AcidRainEvent.UpdateInvasion(); } #endregion diff --git a/World/Abyss.cs b/World/Abyss.cs index e63c4a6171..ba826d1a67 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -72,6 +72,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(); @@ -326,13 +327,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); - } - } } } } @@ -758,9 +752,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, @@ -777,12 +792,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 0241a79a34..73ad082a3e 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 From 649271cf7a303c97ad6176df3b36661881ae1e16 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sat, 30 May 2020 23:07:39 -0400 Subject: [PATCH 23/53] minion anti clump util doesn't actually compile atm due to ID errors but that's unrelated --- Projectiles/CalamityGlobalProjectile.cs | 73 ++++++------------- Projectiles/Summon/ApexShark.cs | 26 +------ Projectiles/Summon/AureusBomber.cs | 27 +------ Projectiles/Summon/BelladonnaSpirit.cs | 27 +------ Projectiles/Summon/BlackHawkSummon.cs | 26 +------ Projectiles/Summon/BloodClotMinion.cs | 25 +------ .../Summon/BrimstoneElementalMinion.cs | 25 +------ Projectiles/Summon/CalamariMinion.cs | 27 +------ Projectiles/Summon/Calamitamini.cs | 25 +------ Projectiles/Summon/Cataclymini.cs | 25 +------ Projectiles/Summon/CausticStaffSummon.cs | 17 +---- Projectiles/Summon/CosmicEnergySpiral.cs | 25 +------ Projectiles/Summon/CosmicViperSummon.cs | 26 +------ Projectiles/Summon/CosmilampMinion.cs | 38 ++-------- Projectiles/Summon/DankCreeperMinion.cs | 30 +------- Projectiles/Summon/DormantBrimseekerBab.cs | 27 +------ Projectiles/Summon/EndoCooperBody.cs | 29 +------- Projectiles/Summon/FungalClumpMinion.cs | 26 +------ Projectiles/Summon/GastricBelcher.cs | 26 +------ Projectiles/Summon/HowlsHeartHowl.cs | 17 +---- Projectiles/Summon/IceSentryShard.cs | 11 --- Projectiles/Summon/MagicAxe.cs | 25 +------ Projectiles/Summon/MagicUmbrella.cs | 26 +------ Projectiles/Summon/MidnightSunUFO.cs | 50 +------------ Projectiles/Summon/MiniGuardianAttack.cs | 6 +- Projectiles/Summon/MiniGuardianDefense.cs | 6 +- Projectiles/Summon/PhantomGuy.cs | 25 +------ Projectiles/Summon/PinkButterfly.cs | 25 +------ Projectiles/Summon/PlaguePrincess.cs | 35 ++------- Projectiles/Summon/PlaguebringerSummon.cs | 26 +------ Projectiles/Summon/PlantSummon.cs | 25 +------ Projectiles/Summon/PurpleButterfly.cs | 28 +------ Projectiles/Summon/SandElementalHealer.cs | 25 +------ Projectiles/Summon/SandElementalMinion.cs | 25 +------ Projectiles/Summon/SandnadoMinion.cs | 26 +------ .../Summon/TacticalPlagueEngineSummon.cs | 27 +------ Projectiles/Summon/VileFeederSummon.cs | 26 +------ Projectiles/Summon/WulfrumDroid.cs | 17 +---- Utilities/CalamityUtils.cs | 27 +++++++ 39 files changed, 105 insertions(+), 923 deletions(-) diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 6b3323c9c9..35c23a980b 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -2154,31 +2154,7 @@ namespace CalamityMod.Projectiles 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; - } - } - } + projectile.MinionAntiClump(); //Breather time between charges as like a reset bool chargeDelay = false; @@ -2379,30 +2355,29 @@ namespace CalamityMod.Projectiles //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; - } - } - } + 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; 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/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/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/BlackHawkSummon.cs b/Projectiles/Summon/BlackHawkSummon.cs index 6161961044..9d0197800d 100644 --- a/Projectiles/Summon/BlackHawkSummon.cs +++ b/Projectiles/Summon/BlackHawkSummon.cs @@ -9,8 +9,6 @@ namespace CalamityMod.Projectiles.Summon { public class BlackHawkSummon : ModProjectile { - private const float PushawayForce = 0.05f; - public override void SetStaticDefaults() { DisplayName.SetDefault("Black Hawk"); @@ -89,29 +87,7 @@ 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; - - if (projectile.position.Y < otherProj.position.Y) - projectile.velocity.Y = projectile.velocity.Y - PushawayForce; - else - projectile.velocity.Y = projectile.velocity.Y + PushawayForce; - } - } + projectile.MinionAntiClump(); Vector2 vector46 = projectile.position; bool flag25 = false; if (player.HasMinionAttackTargetNPC) 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/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/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/CosmicEnergySpiral.cs b/Projectiles/Summon/CosmicEnergySpiral.cs index 45717ba2b1..76f7785437 100644 --- a/Projectiles/Summon/CosmicEnergySpiral.cs +++ b/Projectiles/Summon/CosmicEnergySpiral.cs @@ -70,30 +70,7 @@ 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.MinionAntiClump(); projectile.rotation += projectile.velocity.X * 0.1f; Vector2 vector46 = projectile.position; bool flag25 = false; diff --git a/Projectiles/Summon/CosmicViperSummon.cs b/Projectiles/Summon/CosmicViperSummon.cs index 9964b27bfd..286043a29a 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; 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/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/HowlsHeartHowl.cs b/Projectiles/Summon/HowlsHeartHowl.cs index 42d0372e46..9e7d20481d 100644 --- a/Projectiles/Summon/HowlsHeartHowl.cs +++ b/Projectiles/Summon/HowlsHeartHowl.cs @@ -85,22 +85,7 @@ 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; - } - } + 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/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/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/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..87c4954d15 100644 --- a/Projectiles/Summon/PurpleButterfly.cs +++ b/Projectiles/Summon/PurpleButterfly.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Projectiles.Summon player.MinionDamage()); projectile.damage = damage2; } - if ((double)Math.Abs(projectile.velocity.X) > 0.2) + if (Math.Abs(projectile.velocity.X) > 0.2f) { projectile.spriteDirection = -projectile.direction; } @@ -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/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..26dae11135 100644 --- a/Projectiles/Summon/SandnadoMinion.cs +++ b/Projectiles/Summon/SandnadoMinion.cs @@ -77,31 +77,7 @@ 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; bool flag = false; 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/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/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 92658a75e7..ec7c35cb27 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -653,6 +653,33 @@ 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; + } + } + } #endregion #region Tile Utilities From 3826395b25aba254c2ef12ec9970bf2b58bf30a9 Mon Sep 17 00:00:00 2001 From: DominicKarma42 <51094361+DominicKarma@users.noreply.github.com> Date: Sun, 31 May 2020 02:34:54 -0500 Subject: [PATCH 24/53] Removed locked rusty chest variants and lockpicks --- Items/Accessories/BrokenWaterFilter.cs | 1 - Items/Accessories/RustyMedallion.cs | 1 - Items/Placeables/Furniture/EffigyOfDecay.cs | 1 - Items/Placeables/Furniture/RustyChest.cs | 2 +- Items/RustyLockpick.cs | 30 ----- Items/RustyLockpick.png | Bin 383 -> 0 bytes Items/Weapons/Summon/RustyBeaconPrototype.cs | 3 +- Projectiles/Summon/RustyDrone.cs | 7 +- Tiles/Abyss/RustyChestLocked.cs | 124 ------------------- Tiles/Abyss/RustyChestLocked.png | Bin 1539 -> 0 bytes Tiles/Abyss/RustyChestLocked_Highlight.png | Bin 845 -> 0 bytes Tiles/Abyss/RustyChestTile.cs | 81 ++++++++++++ Tiles/Abyss/RustyChestTile.png | Bin 0 -> 995 bytes Tiles/Abyss/RustyChestTile_Highlight.png | Bin 0 -> 632 bytes World/Abyss.cs | 2 +- World/WorldGenerationMethods.cs | 2 +- 16 files changed, 88 insertions(+), 166 deletions(-) delete mode 100644 Items/RustyLockpick.cs delete mode 100644 Items/RustyLockpick.png delete mode 100644 Tiles/Abyss/RustyChestLocked.cs delete mode 100644 Tiles/Abyss/RustyChestLocked.png delete mode 100644 Tiles/Abyss/RustyChestLocked_Highlight.png create mode 100644 Tiles/Abyss/RustyChestTile.cs create mode 100644 Tiles/Abyss/RustyChestTile.png create mode 100644 Tiles/Abyss/RustyChestTile_Highlight.png 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 9d29b47034..df33a26427 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/Placeables/Furniture/EffigyOfDecay.cs b/Items/Placeables/Furniture/EffigyOfDecay.cs index 50eb4a6b11..1121f4a65e 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 0230fb4cbc..4a01ba73f0 100644 --- a/Items/Placeables/Furniture/RustyChest.cs +++ b/Items/Placeables/Furniture/RustyChest.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Placeables.Furniture item.useStyle = 1; 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 428130670976701b49c3a639a8fe24008b57ef8b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 383 zcmV-_0f7FAP)Px$IY~r8R5*>ble6%&HNxFnJti_NUen&4$Oe>Zc^&&Rn5CTM+S2Y{aMsd4elB;!vK@sE17 z27sKM2Ov;Y1#o;Y0O0)MCK)js|0v`o0A4Gs?P#w8!0A~NfYrJy(jkgm830T904%s$ zqsW_KxV>+ah!}NM69ENqvbzaD=^)h{g1JUnxqD=$%sO4 zO5U;n@P|WVHy@rmQEn>4s76iNU#=MmjW431e-pnM9ckl8`|rlzDw`3ZH&6ip&ATE1 z8i4S@Fh;)r|+fGiaSfY%MLB)vImxz3aEj+3;~o8#1tQCH)VmGI)d dj(LZPiJ!JkSw?dqqYVH6002ovPDHLkV1kjZpB(@I diff --git a/Items/Weapons/Summon/RustyBeaconPrototype.cs b/Items/Weapons/Summon/RustyBeaconPrototype.cs index c71acf5653..6391d1fcfa 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/Projectiles/Summon/RustyDrone.cs b/Projectiles/Summon/RustyDrone.cs index 20ee399b79..49615484ba 100644 --- a/Projectiles/Summon/RustyDrone.cs +++ b/Projectiles/Summon/RustyDrone.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.Summon; -using CalamityMod.Buffs.Cooldowns; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Terraria; @@ -16,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 @@ -139,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/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 e88cc3af08cae44425ffbcd12207ba60254c3e63..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1539 zcmZ8hdpOf;9RCe-m~2Ql<eYjLJ_ z*-RkTa%w)@l51_DAuVUknQoMchs_liN%)AGZ3ecL1T99K0Mm0sTG!*)vqZF&I6arQ zc00xwkD=*xMV}?rKfPL5Sg2Aw92O{YH2GY1nKgQ~o6qD_wsl9l7JgPmx7kH)t4`_X z&fe2g+hSycxy%=drAM#08o%BvZyGU@1&^{8jq^3$@j6!FJ6CPPjqH~aT6T8lb6qY1XMQ?%Kh-r=;a)*qT1}%tycn8Uir(|)AaVaX(=J0UYgau^?tKi zpNe5Wtgn#bj$xTR{EPUsF>+x|nz-aq1>$^;J;r>abRe{Cy{Ufzrudn$$FQt{rg5it zPfESaj4<^FMrVe0q%m&R9w4;;@?|Ky$*c&YxYFK8 zK7UP^IJz;7Ei=jVAlH6+E1cB3ir|I#JQvmaolyQmO~yT2>SJtu9X>qV$pa!2m*&z=en#uu%-np*+ksxH_2~CS+(>Fb&R02wUdRl>4CyPlF*dWY0Hx5_f;}7Lve3>**K_X}ZL;D0cdJ?gcknPjQ=BQjgm6w>bul zLX&)Fcuh3P$|umcnvW@$rAK-?0U>;($}|vrA-y~LRT;z~hBCzQ8KjgJLu_}jr1>(6 z0z+nuFgk)*+8xwJRGmd{5NosAb5YmMWbbrQSxpjh3)#w1iV_^AO+|7K6uGE>;Wh=X zcmIN)`xNfg4X@gu)r=OvYlVyCL2OyE<=uoWyEhqEV%h2UlnPx=L$YB=?wqQm?x4ec5*8D8?DoL`1-yL%Y;PYgM2uq(a(iRn{ziVoNV;mRDc=sNSf5j;^UWy&lWE^Dab1e;v`x5@FIrO|+E=M&nZbZQ*@~Z0HV(c$ z4(qQWCJQqlRAL(s6D}cOVmB#oyd{SN(Xk(Jtp!`tEqdIc@*4eSxe8 z^JB+Gv|m>epYGhMOR=X*%hP>}c6p>pB2U^6h`Nf#+3}W1O;NFpESo*~;WO(m_(CBK z+rFcRyX{gTEhZ5Pjav|?L7SKiIMuLK1p71G#L{9#!_LZ9C0g?q=@lq)7DpY@y+8fz zkchKq)*@XEG}tI2ghgt$Q{fvhN9Nn{1`ISV`@iy0XB4uLSEsD@Vq0|V0|PZ!6KinzD8_Gg7SO0<2vtK+56(R+(C zOw6&xWrIl09`1Z69Tjl_og-c!^!6}p+$7SYAeN*Z(IJ*3Trz!Xk9A|s@sBe%SD$+( zFi*ba=KgfP_umW4jCMc%Sz{M;^H@?yBO@a-6B`Q;N6+%hFFX4;o=h={yYuF1j@j?$ zdzK#m9X9JaAJcK!kW~sVU)7fE54-+6nZ41CeXVrqgH9xhKXl!;MXIOe z$~8b{KQhg@>gBq1YIgL))T`%!0>{cfM}|-BDr#M1BX4`(bk=!3rgxsq)*Lr9V)4rrrJuc|%JpOXlTSW-{5jL6=8JZ(D!aY?(vP1XUN@=x{a3m7cJ%d272kjQ zNwpv2V_Li3@%MMRWgic|tCLD*x3#??{dRB7q`dj8Wda$p7oJ|6{^k3}->bh&fBM_~ z{9IL_;F=}x@7(g#K5;$&erW8R3|5)D`wETs{yW?LT|F+|$}e8~#R`-4vMf^n&pucA zy(-40?(N^G*uDDqw>LX{omUdSqWRiczO0iC4Un+76Ub5~@F9GiX+^}p7MEPbHo0kSPk1e5&{Qipu^+fHCyyF7Jl{ijDJ0A-A%^@8z;qu zrzRhtYV~o;`Qv;{&HsCo*60A^_UArX7PkA2uhZDKrhp<8+#;>lBa&&a6AydQ*VkK(9a*Gwqz|`bnDdCwI4QRJ>S^u z@ObynHLJZ`cRB^m>!0^t>TEhYgTe~DWM4f DO(J%R 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 0000000000000000000000000000000000000000..56fa385bc1f723d7c1d8d4f89b636349e9b9cc09 GIT binary patch literal 995 zcmV<9104K`P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!2kdb!2!6DYwZ9419(Y9K~#8N?V8(5 zR8bVhXCyCpK~qb?EG;S+>LKev=!OsxL`4wzQ2hlVg!vHu0n&p>4@LigK~Mw{LWB_A zzz6fCkS>IgbTQHlOROMce=}>)HM3g#l)^f(f3W#Zr|p@&zq9t7eLf~RKR=(aL_tQ) z5C)_X2BeW(-`KQhnZ0^5mdqS3D;w4}=lxu}4jtLO87FQ&cnD z+IQ&GiLE$sss9O-X3$Vv2<5aLt%bICT*J)zx)0+zckfL(5g|wT9Wm?Bii~C%oA?YR z$0Yi%zK6DVK(fwkY$}IJ3=F5QFJZ5Sl0}uc_q}KK;6&H?`%q4E-O9{S8mfW5E4LTb z5Y-?-j&n{QYlU98J_P;secI?M3;Q93Yz^^yN;OkgvmMH5O?`z@4ISFK3)h*Pt#^{c z#N=Zr)zrZqTc88OPoZXO$a_F;h6~%!XgM0;oNI-&;BlGXG;&1 zJJdJQo#?*Pi{rn+oI{ZZv?}oq?b+lY8bSYd|MxH0t0A7k)>l{H8}q}|j8}0*%^0i7 zO3{D%+w7wL_A^GF`7L+G82=Pj%NWUtTaO-MW|V$t86(|+_@}TuYm_oZqHS+A)Hh?4 zFy~N#?;9%hllr@wa!u>U;r;Bbvan-R2q~%4rOexsF=H0hV5_A^E)h1GVB*=LZlW2D_g>{8h5fYz)lLL;0rzWZt)`1M?k z<*PHh4iQn`$D*QL-=0Iu?T7~dd~*(k9iv9%6qY9$(l<4K|DwE!>gE4SVF@?$g^iHT zMslu#0|OJUr;B4qMcmsN8@-qV1zgL8r!;i*-r@`s zQ*u&@;4=HyYOg3ZiJwFBh}Q@GKMWf;iS#IlC22==h$RV|C~iu2J8|UsU6tKwO5YC{ z?Y?RLJ5TR-n!Iqi)!Y-pt$8KPtcn^Og4?6k&Pxr`5qtbDbKREPZ{?qVeLX>I%PGOg zr@r%?t7H%LdCyKSd>=4>fy>JU|Bbx=SWgjqof3BLS9Izfenu`&*$Ytyd~g2zPoMgf z6=a^HBS(4Dud*IRr>ilaFZ>mlwfylP%O&yEt3x>d&YR{q-`ev1g%#%_E?GUjuIL?h zF5-${cYOPf&s6lLim8UBg{!n_TwShe#(z(>Eo0AJ@0tud&zgS~ zQ+HTx)+zkGM5pl6{e`#A?K`s9%Xd-fixq*rtJ2$x?0DYENJU(5`l50C?&+N}U2*E) z-45QjPSO5)%`H;v+0m<|tEPKv=d56gHoJZ;_0Q9{zUM3c-#7a0|M}mv)@PshpAuSH zxpQ*Ey!ZDP7CM7`vLo4L19$fV1s15^ZnV0F#(Z{qeBoX2=aM=0?KfIkf$|CBVh3$a zo0MKdVPFDrC2@RO|QA(t=l5p?}oj~ckDd0zerutM1Hz0SY?5FhqW8a z?hPDVP5}a7k%rg^)sVBM{CD{mR$85#@BHQv6VN`O`48s(Dqr+MnCVPyZ&h7XA~3Zu Nc)I$ztaD0e0sx9`5b*#2 literal 0 HcmV?d00001 diff --git a/World/Abyss.cs b/World/Abyss.cs index ba826d1a67..31232fee81 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -737,7 +737,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()); } } } diff --git a/World/WorldGenerationMethods.cs b/World/WorldGenerationMethods.cs index 6cf3b5a228..d641ea220f 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); From 6fa3949c2b5994d05c811b63a63ea38e9436778d Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 11:02:07 -0400 Subject: [PATCH 25/53] organic/inorganic utilities --- Projectiles/DraedonsArsenal/PulseRifleShot.cs | 14 +----- .../DraedonsArsenal/TeslaCannonShot.cs | 6 +-- Projectiles/Ranged/ImpactRound.cs | 14 +----- .../Typeless/FiniteUse/GrenadeRound.cs | 14 +----- Projectiles/Typeless/FiniteUse/MagnumRound.cs | 9 +--- Utilities/CalamityUtils.cs | 49 +++++++++++++++++++ 6 files changed, 54 insertions(+), 52 deletions(-) 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/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/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/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index ec7c35cb27..c9b346a12b 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -2,6 +2,8 @@ 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.Tiles; using CalamityMod.Tiles.Abyss; @@ -216,6 +218,53 @@ 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.HitSound != mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AngryDogHit") && + target.type != ModContent.NPCType() && target.type != ModContent.NPCType()) + { + return true; + } + return false; + } #endregion #region Item Utilities From 14bd5347985cccb182d5ab52a360779e0fc3dea6 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 11:25:03 -0400 Subject: [PATCH 26/53] moved charging AI to calamityutils --- Items/Weapons/Melee/Murasama.cs | 1 - Projectiles/CalamityGlobalProjectile.cs | 201 -------------------- Projectiles/Magic/AtlantisSpear.cs | 1 - Projectiles/Ranged/AMRShot.cs | 1 - Projectiles/Summon/AquaticStarMinion.cs | 2 +- Projectiles/Summon/BrittleStarMinion.cs | 2 +- Projectiles/Summon/Catastromini.cs | 2 +- Projectiles/Summon/CloudElementalMinion.cs | 2 +- Projectiles/Summon/ElementalAxeMinion.cs | 2 +- Projectiles/Summon/HerringMinion.cs | 2 +- Projectiles/Summon/IceClasperMinion.cs | 2 +- Projectiles/Summon/LuxorsGiftSummon.cs | 2 +- Projectiles/Summon/SonOfYharon.cs | 2 +- Projectiles/Summon/Valkyrie.cs | 2 +- Utilities/CalamityUtils.cs | 205 ++++++++++++++++++++- 15 files changed, 213 insertions(+), 216 deletions(-) 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/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 35c23a980b..ecffd53767 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -2148,207 +2148,6 @@ namespace CalamityMod.Projectiles } } - 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 - 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); - //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]; 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/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/Summon/AquaticStarMinion.cs b/Projectiles/Summon/AquaticStarMinion.cs index 10eed0167d..896416b87e 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, 8f, false, false); } public override bool OnTileCollide(Vector2 oldVelocity) => false; diff --git a/Projectiles/Summon/BrittleStarMinion.cs b/Projectiles/Summon/BrittleStarMinion.cs index 4b1675e06e..5e2699a5a7 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, 8f, false, false); } public override bool OnTileCollide(Vector2 oldVelocity) => false; 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/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/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/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/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/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/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/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/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index c9b346a12b..09c4b4e12b 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -5,6 +5,7 @@ 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; @@ -257,8 +258,7 @@ namespace CalamityMod 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.HitSound != mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AngryDogHit") && + target.HitSound != SoundID.NPCHit56 && target.HitSound != SoundID.NPCHit57 && target.type != ModContent.NPCType() && target.type != ModContent.NPCType() && target.type != ModContent.NPCType()) { return true; @@ -729,6 +729,207 @@ namespace CalamityMod } } } + + 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); + //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; + } + } + } + } #endregion #region Tile Utilities From 6bc76a81bbe4a66336004840c977dcd97f8a4964 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 11:35:28 -0400 Subject: [PATCH 27/53] Moved pet AI to calamityutils --- Projectiles/CalamityGlobalProjectile.cs | 130 ---------------------- Projectiles/Pets/Akato.cs | 2 +- Projectiles/Pets/BabyGhostBell.cs | 2 +- Projectiles/Pets/LeviPet.cs | 2 +- Projectiles/Pets/PerforaMini.cs | 2 +- Projectiles/Pets/PlaguebringerBab.cs | 2 +- Projectiles/Pets/RotomPet.cs | 2 +- Projectiles/Pets/SCalPet.cs | 2 +- Projectiles/Pets/ThirdSage.cs | 2 +- Projectiles/Summon/HowlsHeartCalcifer.cs | 2 +- Utilities/CalamityUtils.cs | 131 +++++++++++++++++++++++ 11 files changed, 140 insertions(+), 139 deletions(-) diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index ecffd53767..7ac7ebda11 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -2148,136 +2148,6 @@ namespace CalamityMod.Projectiles } } - 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 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 ExpandHitboxBy(Projectile projectile, int width, int height) { projectile.position = projectile.Center; 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/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/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 09c4b4e12b..73cfe5c19b 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -930,6 +930,137 @@ namespace CalamityMod } } } + + 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; + } #endregion #region Tile Utilities From e8116069b01597e4809dfcde765bc1ee3478eb96 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 11:37:32 -0400 Subject: [PATCH 28/53] magic rifle tweak --- Projectiles/Summon/MagicRifle.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Projectiles/Summon/MagicRifle.cs b/Projectiles/Summon/MagicRifle.cs index 28dd81754b..a75dfd38ab 100644 --- a/Projectiles/Summon/MagicRifle.cs +++ b/Projectiles/Summon/MagicRifle.cs @@ -171,8 +171,8 @@ namespace CalamityMod.Projectiles.Summon } 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)); + projectile.spriteDirection = projectile.direction = ((vector46.X - projectile.Center.X) > 0).ToDirectionInt(); + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(vector46) + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(135)), 0.1f); } else { From 549c0651923592883532d6dff1ba892dc8f927ea Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 11:40:27 -0400 Subject: [PATCH 29/53] moved healing projectile AI to calamityutils --- Projectiles/CalamityGlobalProjectile.cs | 46 -------------------- Projectiles/Healing/AtaxiaHealOrb.cs | 2 +- Projectiles/Healing/AuricOrb.cs | 2 +- Projectiles/Healing/BurntSiennaProj.cs | 2 +- Projectiles/Healing/CactusHealOrb.cs | 2 +- Projectiles/Healing/EarthHealOrb.cs | 2 +- Projectiles/Healing/EssenceFlame.cs | 2 +- Projectiles/Healing/Exoheal.cs | 2 +- Projectiles/Healing/FungalHeal.cs | 2 +- Projectiles/Healing/GodSlayerHealOrb.cs | 2 +- Projectiles/Healing/ManaOverloaderHealOrb.cs | 2 +- Projectiles/Healing/PhoenixHeal.cs | 2 +- Projectiles/Healing/RainHeal.cs | 2 +- Projectiles/Healing/RoyalHeal.cs | 2 +- Projectiles/Healing/ShinobiHealOrb.cs | 2 +- Projectiles/Healing/SilvaOrb.cs | 2 +- Projectiles/Healing/TerracottaProj.cs | 2 +- Projectiles/Healing/TransfusionTrail.cs | 2 +- Projectiles/Healing/XerocHealOrb.cs | 2 +- Utilities/CalamityUtils.cs | 46 ++++++++++++++++++++ 20 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 7ac7ebda11..a664be8030 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -2102,52 +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 ExpandHitboxBy(Projectile projectile, int width, int height) { projectile.position = projectile.Center; 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/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 73cfe5c19b..c063305455 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -1061,6 +1061,52 @@ namespace CalamityMod 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 From e0c7064fb2ca5e399d4f1120b816202ab559ce20 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 11:46:33 -0400 Subject: [PATCH 30/53] purple butterfly now uses charging minion AI --- Projectiles/Summon/PurpleButterfly.cs | 347 ++++++++------------------ Utilities/CalamityUtils.cs | 6 +- 2 files changed, 103 insertions(+), 250 deletions(-) diff --git a/Projectiles/Summon/PurpleButterfly.cs b/Projectiles/Summon/PurpleButterfly.cs index 87c4954d15..d82b2b4382 100644 --- a/Projectiles/Summon/PurpleButterfly.cs +++ b/Projectiles/Summon/PurpleButterfly.cs @@ -8,257 +8,108 @@ 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 (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); - 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; - } - } - projectile.MinionAntiClump(); - 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); + float num633 = 1200f; + float num634 = 1500f; + float num635 = 2400f; + float num636 = 150f; + 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/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index c063305455..72cf2e72f1 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -767,11 +767,13 @@ namespace CalamityMod Vector2 targetVec = projectile.position; bool foundTarget = false; Vector2 half = new Vector2(0.5f); + bool isButterfly = projectile.type == ModContent.ProjectileType(); + bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly; //Prioritize the targeted enemy if possible if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false)) + 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; @@ -794,7 +796,7 @@ namespace CalamityMod for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) { NPC npc = Main.npc[npcIndex]; - if (npc.CanBeChasedBy(projectile, false)) + if (npc.CanBeChasedBy(projectile, false) || fishronCheck) { Vector2 sizeCheck = npc.position + npc.Size * half; float targetDist = Vector2.Distance(npc.Center, projectile.Center); From bc31b39673cd1ab3091079fd933dc939efac0e92 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 12:05:34 -0400 Subject: [PATCH 31/53] refactored black hawks --- Projectiles/Summon/BlackHawkSummon.cs | 214 +++++++----- Projectiles/Summon/PurpleButterfly.cs | 4 - Utilities/CalamityUtils.cs | 475 +++++++++++++------------- 3 files changed, 363 insertions(+), 330 deletions(-) diff --git a/Projectiles/Summon/BlackHawkSummon.cs b/Projectiles/Summon/BlackHawkSummon.cs index 9d0197800d..e62818c4fe 100644 --- a/Projectiles/Summon/BlackHawkSummon.cs +++ b/Projectiles/Summon/BlackHawkSummon.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; +using CalamityMod.Projectiles; using Microsoft.Xna.Framework; using System; using Terraria; @@ -35,45 +36,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) @@ -87,149 +95,177 @@ namespace CalamityMod.Projectiles.Summon projectile.timeLeft = 2; } } + + //Anti sticky movement to prevent overlapping minions projectile.MinionAntiClump(); - 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() - { - return false; - } + //Does no contact damage + public override bool CanDamage() => false; } } diff --git a/Projectiles/Summon/PurpleButterfly.cs b/Projectiles/Summon/PurpleButterfly.cs index d82b2b4382..0927822a9d 100644 --- a/Projectiles/Summon/PurpleButterfly.cs +++ b/Projectiles/Summon/PurpleButterfly.cs @@ -77,10 +77,6 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } Lighting.AddLight(projectile.Center, 0.3f, 0f, 0.5f); - float num633 = 1200f; - float num634 = 1500f; - float num635 = 2400f; - float num636 = 150f; 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); diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 72cf2e72f1..f4931c6f06 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -732,213 +732,214 @@ namespace CalamityMod 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(); + 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; - } + 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); + float maxDist = range; + Vector2 targetVec = projectile.position; + bool foundTarget = false; + Vector2 half = new Vector2(0.5f); bool isButterfly = projectile.type == ModContent.ProjectileType(); - bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly; //Prioritize the targeted enemy if possible - if (player.HasMinionAttackTargetNPC) - { - NPC npc = Main.npc[player.MinionAttackTargetNPC]; - if (npc.CanBeChasedBy(projectile, false) || fishronCheck) - { + 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); + 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 (!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) || fishronCheck) - { + 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); + 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 (!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; - } + 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) - { + 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(); + 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 - } - } + 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 - { + 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; - } + 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(); + 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; - } + float playerHomeSpeed = 6f; + if (returningToPlayer) + { + playerHomeSpeed = 15f; + } //Move somewhat faster if the player is kinda far~ish - if (playerDist > 200f && playerHomeSpeed < 8f) - { - playerHomeSpeed = 8f; - } + 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; - } + 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 (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; - } + 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; - } - } + 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 (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; - } + 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; - } - } - } - } + 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; + float SAImovement = 0.05f; for (int k = 0; k < Main.maxProjectiles; k++) { Projectile otherProj = Main.projectile[k]; @@ -963,94 +964,94 @@ namespace CalamityMod } } - 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); + 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; + xDist += 60f * (lightPet ? (float)player.direction : -(float)player.direction); + yDist -= 60f; Vector2 playerVector = new Vector2(xDist, yDist); - float playerDist = playerVector.Length(); - float returnSpeed = 18f; + 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; - } - } + 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 > 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 (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; From d6d5bc44907ed4b73713bc72c624be8bc349e2cc Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 12:47:29 -0400 Subject: [PATCH 32/53] added glowmasks to black hawks and viper jets --- Projectiles/Summon/BlackHawkGlow.png | Bin 0 -> 708 bytes Projectiles/Summon/BlackHawkSummon.cs | 27 ++++++++++++++++++++++++ Projectiles/Summon/CosmicViperGlow.png | Bin 0 -> 855 bytes Projectiles/Summon/CosmicViperSummon.cs | 22 ++++++++++++++----- 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 Projectiles/Summon/BlackHawkGlow.png create mode 100644 Projectiles/Summon/CosmicViperGlow.png diff --git a/Projectiles/Summon/BlackHawkGlow.png b/Projectiles/Summon/BlackHawkGlow.png new file mode 100644 index 0000000000000000000000000000000000000000..24479cb83969ea319e93c156b0723570a1a82040 GIT binary patch literal 708 zcmV;#0z3VQP)5PefX5v?fVW554C-^=yk;JPWUAASY^h{p1^yCPcQ z;RfP)x9hy&_IOm?L+$u{15`I*v5U0}sU6=82n(2&bGRwOauF7Dg$40&bJuy0eBHl2 zjjk0CtyGp4vi>`VnCN!9?M;0;ow}c2Kfk)~xkADz0uY(Bq;$^}C(4lDi$cOFLKe7s z5QIjO0w6LoppHmD0HG{Q!e)(99&R9NAET{Xe1M4htWg>ga=n`(v^TueICl`%v91LL z2t1;%9d|`&rEEP85QGMy@o!WS8iWR+L1>JnTs#7gz$5SoJYvR!iMv_W_AY0van>b( zAZw5{+R7U8N^a_G(@=n0_d4A?0uZx2{PGvMDdO@=9sk5|AWDw|gniQmh_to&(V?mH zm0=YDh|CLzju$?@ymwcIKY1%WRu6*Ez%2XbK>AEP08v@9hbytQJlsIkK8Dwh&w&Ag zo+UlYwtALwH@w%#Dnac(%WJblGiGVE0IPZ2vWC?HtmXj(>67%?X8N>>@!EOt2s{Fh zz$3S;M8;II-lGY&w2ns3+s@MgU z_Beo0ar1~`Tb~#JhzyWqBRO9=_r*~dMF 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/CosmicViperGlow.png b/Projectiles/Summon/CosmicViperGlow.png new file mode 100644 index 0000000000000000000000000000000000000000..4f35f5fc007aeb8e2c2d532ed1d1a3d90219f22d GIT binary patch literal 855 zcmV-d1E~CoP) zO=5nMN;xK}73!K4i?BGN#R|2;#*eR4bM@z8G^M#N+3ZBs3+-;KM1>HwGETI0%eq6i zSfSJqE@qC35!&B7H&O9xZDDHEy&dgD9sceRc89o)#$3X|om3-q>3V304tE!g$tTB8 z=JR>KZ$4uMk5HnaiN($Kz3F!_Q8hyC(7n7`H)bxMeVb42T%m43p+vdu1`|~ylp+!9 zdtc7WCFu4im}o2^R6WHDRg(g$6^iFkYLa`t&mN52#j((ghpQJtxsFvWuXee!Zerjw zJp0hCIuf|oK`7TT>E%IGIw5ZVK$Pp4^ztAooe;NwAj)-2dU+6)PKet-5al{1y*!9Y zC&cX^h;kj1ULHi7B9v-VN!)Il8ll$tR6E_aelc?tLOsEPd)}xuL|whD73!O-vGz&D z5EUa-+7UT-C{vqL!9>*vm2yPRl62=TML3wK8llpT$Wa6<=elZy=6;&7?Nia!*U#WN z3Zao4ppyDxQa}iupyVd;m7{K?5$dgmBHDVPYL-&e2u(dD#H|^n7A!7dNF^9TQ#qTf zUJ%XYe5!UqG?lZt>IKnU&ZlY@L{mANt6mVz<$S7kK{S=Kx#|Vcrk%IHI=ub-Fijuc zZAFC;wX!Nsqpuz6 z_PWsMEH3J*6H09=aewVEmT0j;?VL;Xau_j0#R$!HM9vp|-3-W0Jly+mFi|x^a~+YR zf|5(t7mb67su7y&h+MWg+Vl$$8y8yVp_+3o?xP&HW|R#MMm5_ZFL$3_sA!8^*JG(z zqIe#iycoE358i5)Qq%}lv)rjhsJjY?y%#d&_`iUd`)Exa 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); } } } From bc61b4d295d21033a4e657c357b815420168518a Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 12:50:35 -0400 Subject: [PATCH 33/53] magic rifle rotation fix --- Projectiles/Summon/MagicRifle.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Projectiles/Summon/MagicRifle.cs b/Projectiles/Summon/MagicRifle.cs index a75dfd38ab..cd60b997b2 100644 --- a/Projectiles/Summon/MagicRifle.cs +++ b/Projectiles/Summon/MagicRifle.cs @@ -172,12 +172,12 @@ namespace CalamityMod.Projectiles.Summon if (flag25) { projectile.spriteDirection = projectile.direction = ((vector46.X - projectile.Center.X) > 0).ToDirectionInt(); - projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(vector46) + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(135)), 0.1f); + projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(vector46) + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(225)), 0.1f); } else { projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(135)); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(225)); } if (projectile.ai[1] > 0f) { From 39d18a91ab4babc4f919c3ea03c5abb41feec607 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 13:30:56 -0400 Subject: [PATCH 34/53] magic rifle refactor --- Projectiles/Summon/MagicRifle.cs | 422 +++++++++++++++---------------- 1 file changed, 211 insertions(+), 211 deletions(-) diff --git a/Projectiles/Summon/MagicRifle.cs b/Projectiles/Summon/MagicRifle.cs index cd60b997b2..4bd927fd33 100644 --- a/Projectiles/Summon/MagicRifle.cs +++ b/Projectiles/Summon/MagicRifle.cs @@ -7,229 +7,229 @@ 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 = ((vector46.X - projectile.Center.X) > 0).ToDirectionInt(); - projectile.rotation = projectile.rotation.AngleTowards(projectile.AngleTo(vector46) + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(225)), 0.1f); - } - else - { + 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) + { + homingRange = targetDist; + targetVec = sizeCheck; + foundTarget = true; + } + } + } + else + { + for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++) + { + NPC npc = Main.npc[npcIndex]; + if (npc.CanBeChasedBy(projectile, false) && canHome) + { + float targetDist = Vector2.Distance(npc.Center, projectile.Center); + if (!foundTarget && targetDist < homingRange) + { + homingRange = targetDist; + targetVec = sizeCheck; + foundTarget = true; + } + } + } + } + + //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; + } + + //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; + } + } + + //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(315) : MathHelper.ToRadians(225)), 0.1f); + } + else + { projectile.spriteDirection = projectile.direction = (projectile.velocity.X > 0).ToDirectionInt(); projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(315) : MathHelper.ToRadians(225)); - } - 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)) - { - 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 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; - } - } - } - } + } - public override Color? GetAlpha(Color lightColor) - { - return new Color(148, 0, 211, projectile.alpha); - } + //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; + } - public override bool CanDamage() - { - return false; - } + //Return if on attack cooldown, has no target, or returning to the player + if (projectile.ai[0] != 0f || !foundTarget || projectile.ai[1] != 0f) + return; - 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; - } - } - } + //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; + } + } + } } From acd548b18bee393b76ba47304d44f5620435f49d Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 13:33:32 -0400 Subject: [PATCH 35/53] missing vector thingy --- Projectiles/Summon/MagicRifle.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Projectiles/Summon/MagicRifle.cs b/Projectiles/Summon/MagicRifle.cs index 4bd927fd33..bf1d253169 100644 --- a/Projectiles/Summon/MagicRifle.cs +++ b/Projectiles/Summon/MagicRifle.cs @@ -73,6 +73,7 @@ namespace CalamityMod.Projectiles.Summon 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) { From 256d2b3e7e3d2c2f98e5f2322cd8338d76501159 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 13:53:42 -0400 Subject: [PATCH 36/53] me when I fix rotation for real this time --- Projectiles/Summon/MagicRifle.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Projectiles/Summon/MagicRifle.cs b/Projectiles/Summon/MagicRifle.cs index bf1d253169..e59667cb4c 100644 --- a/Projectiles/Summon/MagicRifle.cs +++ b/Projectiles/Summon/MagicRifle.cs @@ -173,12 +173,12 @@ namespace CalamityMod.Projectiles.Summon 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(315) : MathHelper.ToRadians(225)), 0.1f); + 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(315) : MathHelper.ToRadians(225)); + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? MathHelper.ToRadians(45) : MathHelper.ToRadians(135)); } //Increment attack cooldown From 1f6610d87df27677d0fde7156d057c15b3c92ec9 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 14:00:33 -0400 Subject: [PATCH 37/53] soul of cryogen no longer spams icicle sounds --- Items/Accessories/Wings/SoulofCryogen.cs | 2 +- Projectiles/Rogue/FrostShardFriendly.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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/Projectiles/Rogue/FrostShardFriendly.cs b/Projectiles/Rogue/FrostShardFriendly.cs index fd43227505..5acb692e02 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.PlaySound(SoundID.Item27, projectile.position); for (int index1 = 0; index1 < 3; ++index1) { int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 76); From 3a34d1aad7a27dcdd3d7403ce26d345e3f6f038e Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 14:00:58 -0400 Subject: [PATCH 38/53] added a small chance for the sound to still play --- Projectiles/Rogue/FrostShardFriendly.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projectiles/Rogue/FrostShardFriendly.cs b/Projectiles/Rogue/FrostShardFriendly.cs index 5acb692e02..c48e26e7bd 100644 --- a/Projectiles/Rogue/FrostShardFriendly.cs +++ b/Projectiles/Rogue/FrostShardFriendly.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - if (projectile.ai[0] != 1f) + if (projectile.ai[0] != 1f || Main.rand.NextBool(20)) Main.PlaySound(SoundID.Item27, projectile.position); for (int index1 = 0; index1 < 3; ++index1) { From 38af94cfa8907eeb38f94bf40857c237b145643f Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 14:06:11 -0400 Subject: [PATCH 39/53] if the player is dead, null, or wrong owner, KILLLLLLLLLLL --- Projectiles/Rogue/FinalDawnFireSlash.cs | 3 +++ Projectiles/Rogue/FinalDawnHorizontalSlash.cs | 4 ++++ Projectiles/Rogue/FinalDawnProjectile.cs | 3 +++ Projectiles/Rogue/FinalDawnThrow.cs | 6 +++++- Projectiles/Rogue/FinalDawnThrow2.cs | 6 +++++- 5 files changed, 20 insertions(+), 2 deletions(-) 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; From 771dc8a1033118f5e2c837cdb3882209baf6b48a Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 22:38:41 -0400 Subject: [PATCH 40/53] nerfed crate drop rates --- Items/Fishing/AstralCatches/AstralCrate.cs | 2 +- Items/Fishing/SulphurCatches/AbyssalCrate.cs | 6 +++--- Items/Fishing/SunkenSeaCatches/SunkenCrate.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) 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/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(), From 01816609db50aceaae4dedb53e87ee04918f039e Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Sun, 31 May 2020 23:17:04 -0400 Subject: [PATCH 41/53] photo left buff --- Items/Weapons/Ranged/Photoviscerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Ranged/Photoviscerator.cs b/Items/Weapons/Ranged/Photoviscerator.cs index 09bcc37c8e..c346c6f2b8 100644 --- a/Items/Weapons/Ranged/Photoviscerator.cs +++ b/Items/Weapons/Ranged/Photoviscerator.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Items.Weapons.Ranged 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)) { From 2b8e488900625f8c487ca0cfc19f4bf4ca0a2921 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Mon, 1 Jun 2020 09:43:31 -0400 Subject: [PATCH 42/53] improved blood crawler counting loop --- Projectiles/Summon/BabyBloodCrawler.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; From c2158e0da5a3249139ecfbbb26d311fd8c2191a3 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Mon, 1 Jun 2020 12:44:06 -0400 Subject: [PATCH 43/53] fixed wof key drop rates --- Items/CalamityGlobalItem.cs | 2 +- NPCs/CalamityGlobalNPCLoot.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 8f7a486be7..52ee2ba370 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -2811,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/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 1f158d932d..8b6541c677 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); From d509daab0c6502a92ef107ab0fbcefd067c11cd0 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:08:39 -0400 Subject: [PATCH 44/53] living fire blocks fixed... probably --- .../LivingBrimstoneFireBlockTile.cs | 104 +++++++++++++----- .../LivingGodSlayerFireBlockTile.cs | 102 ++++++++++++----- Tiles/LivingFire/LivingHolyFireBlockTile.cs | 103 ++++++++++++----- 3 files changed, 229 insertions(+), 80 deletions(-) diff --git a/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs b/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs index 49e4b83c8e..74118d3786 100644 --- a/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs +++ b/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs @@ -9,38 +9,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] || tile.type == 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..6ca183c3fa 100644 --- a/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs +++ b/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs @@ -9,37 +9,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] || tile.type == 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..b8e74a4553 100644 --- a/Tiles/LivingFire/LivingHolyFireBlockTile.cs +++ b/Tiles/LivingFire/LivingHolyFireBlockTile.cs @@ -9,38 +9,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] || tile.type == 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; + } + } } From 71dfde16d34daa063e0aedf10b028efe4f23d580 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:40:25 -0400 Subject: [PATCH 45/53] using directives :godflushed: --- Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs | 2 ++ Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs | 2 ++ Tiles/LivingFire/LivingHolyFireBlockTile.cs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs b/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs index 74118d3786..f62f4cc6de 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; diff --git a/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs b/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs index 6ca183c3fa..3f452f7b01 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; diff --git a/Tiles/LivingFire/LivingHolyFireBlockTile.cs b/Tiles/LivingFire/LivingHolyFireBlockTile.cs index b8e74a4553..f49be7de88 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; From 36e3dbc930571018ae366597a5f18d7391d7f107 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:47:06 -0400 Subject: [PATCH 46/53] improved some magic bullet code and added whispering death debuff --- Projectiles/Summon/MagicBullet.cs | 93 +++++++++++++++++-------------- 1 file changed, 50 insertions(+), 43 deletions(-) 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); + } + } } From 79de5884258c35866795bc3a0f57f7641d426cf0 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Wed, 3 Jun 2020 11:04:47 -0400 Subject: [PATCH 47/53] living fire blocks now check for other living fire blocks --- CalamityMod.cs | 16 ++++++++++++++++ Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs | 2 +- Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs | 2 +- Tiles/LivingFire/LivingHolyFireBlockTile.cs | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CalamityMod.cs b/CalamityMod.cs index 85b15eaeb6..f5da20e3ad 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, diff --git a/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs b/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs index f62f4cc6de..e7a37e66cc 100644 --- a/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs +++ b/Tiles/LivingFire/LivingBrimstoneFireBlockTile.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Tiles.LivingFire 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] || tile.type == Type)) + if (tile.active() && (Main.tileSolid[tile.type] || CalamityMod.livingFireBlockList.Contains(tile.type))) { return true; } diff --git a/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs b/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs index 3f452f7b01..039532b093 100644 --- a/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs +++ b/Tiles/LivingFire/LivingGodSlayerFireBlockTile.cs @@ -68,7 +68,7 @@ namespace CalamityMod.Tiles.LivingFire 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] || tile.type == Type)) + if (tile.active() && (Main.tileSolid[tile.type] || CalamityMod.livingFireBlockList.Contains(tile.type))) { return true; } diff --git a/Tiles/LivingFire/LivingHolyFireBlockTile.cs b/Tiles/LivingFire/LivingHolyFireBlockTile.cs index f49be7de88..6d334a5e41 100644 --- a/Tiles/LivingFire/LivingHolyFireBlockTile.cs +++ b/Tiles/LivingFire/LivingHolyFireBlockTile.cs @@ -68,7 +68,7 @@ namespace CalamityMod.Tiles.LivingFire 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] || tile.type == Type)) + if (tile.active() && (Main.tileSolid[tile.type] || CalamityMod.livingFireBlockList.Contains(tile.type))) { return true; } From 83917e6fb44d23630538ee85a7771202a3c3f915 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Wed, 3 Jun 2020 14:28:20 -0400 Subject: [PATCH 48/53] added a holdoutoffset to Opal Striker --- Items/Weapons/Ranged/OpalStriker.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Items/Weapons/Ranged/OpalStriker.cs b/Items/Weapons/Ranged/OpalStriker.cs index 2334271703..0ff489c56b 100644 --- a/Items/Weapons/Ranged/OpalStriker.cs +++ b/Items/Weapons/Ranged/OpalStriker.cs @@ -35,9 +35,11 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = 97; } + public override Vector2? HoldoutOffset() => new Vector2(-10, 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, 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); return false; } From 560dfc9f7aa0fe302ec1131d2aee222c763cc49e Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Wed, 3 Jun 2020 14:28:44 -0400 Subject: [PATCH 49/53] spacing stuff --- Items/Weapons/Ranged/OpalStriker.cs | 90 ++++++++++++++--------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/Items/Weapons/Ranged/OpalStriker.cs b/Items/Weapons/Ranged/OpalStriker.cs index 0ff489c56b..e02eeb06e3 100644 --- a/Items/Weapons/Ranged/OpalStriker.cs +++ b/Items/Weapons/Ranged/OpalStriker.cs @@ -6,53 +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 Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override Vector2? HoldoutOffset() => new Vector2(-10, 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, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - 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); + 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(); - } - } + 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(); + } + } } From 91e07c0532703a68065d08dfeda5147b457d39bb Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Wed, 3 Jun 2020 14:42:16 -0400 Subject: [PATCH 50/53] vivid tweaks --- Items/Weapons/Magic/VividClarity.cs | 33 ++++++++++++++--------------- Projectiles/Magic/VividBeam.cs | 31 +++++++++++++-------------- 2 files changed, 31 insertions(+), 33 deletions(-) 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/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); } } } From 01426576e1359551ab4e3a94d406aefa517317ce Mon Sep 17 00:00:00 2001 From: Cameron Ewell Date: Wed, 3 Jun 2020 21:23:35 -0400 Subject: [PATCH 51/53] Removed two unnecessary minion anti-clump calls --- Projectiles/Summon/CosmicEnergySpiral.cs | 1 - Projectiles/Summon/HowlsHeartHowl.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/Projectiles/Summon/CosmicEnergySpiral.cs b/Projectiles/Summon/CosmicEnergySpiral.cs index 76f7785437..64fe2da558 100644 --- a/Projectiles/Summon/CosmicEnergySpiral.cs +++ b/Projectiles/Summon/CosmicEnergySpiral.cs @@ -70,7 +70,6 @@ namespace CalamityMod.Projectiles.Summon float num634 = 1600f; //800 float num635 = 2400f; //1200 float num636 = 800f; - projectile.MinionAntiClump(); projectile.rotation += projectile.velocity.X * 0.1f; Vector2 vector46 = projectile.position; bool flag25 = false; diff --git a/Projectiles/Summon/HowlsHeartHowl.cs b/Projectiles/Summon/HowlsHeartHowl.cs index 9e7d20481d..caf409d2de 100644 --- a/Projectiles/Summon/HowlsHeartHowl.cs +++ b/Projectiles/Summon/HowlsHeartHowl.cs @@ -85,7 +85,6 @@ namespace CalamityMod.Projectiles.Summon } //Anti sticky movement although there should only be one - projectile.MinionAntiClump(); //Set tile collision for only when trying to return to the player projectile.tileCollide = projectile.ai[0] != 1f; From 4bf74147adc5e1d810fb70af9c63ba8f0a9ebb08 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Wed, 3 Jun 2020 22:26:41 -0400 Subject: [PATCH 52/53] Rebalanced Elemental Eruption and Elemental Blaster --- Items/Weapons/Ranged/ElementalBlaster.cs | 2 +- Items/Weapons/Ranged/ElementalEruption.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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; From bb3186c35817a9fe28ebcb2b3438b06e22219af3 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Wed, 3 Jun 2020 23:40:36 -0400 Subject: [PATCH 53/53] photoviscerator mysteriously died --- Items/Weapons/Ranged/Photoviscerator.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Items/Weapons/Ranged/Photoviscerator.cs b/Items/Weapons/Ranged/Photoviscerator.cs index c346c6f2b8..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,7 +70,7 @@ 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(), (int)(damage * 2.3), knockBack, player.whoAmI); + Projectile.NewProjectile(position, velocity.SafeNormalize(Vector2.Zero) * 17f, ModContent.ProjectileType(), (int)(damage * AltFireDamageMult), knockBack, player.whoAmI); } else {