diff --git a/BiomeManagers/SulphurousSeaBiome.cs b/BiomeManagers/SulphurousSeaBiome.cs index fa66391e6a..080be1531c 100644 --- a/BiomeManagers/SulphurousSeaBiome.cs +++ b/BiomeManagers/SulphurousSeaBiome.cs @@ -30,7 +30,7 @@ namespace CalamityMod.BiomeManagers if (acidRain) { music = DownedBossSystem.downedPolterghast - ? CalamityMod.Instance.GetMusicFromMusicMod("AcidRain2") ?? MusicID.Eclipse // Acid Rain Tier 3 + ? CalamityMod.Instance.GetMusicFromMusicMod("AcidRain2") ?? MusicID.Monsoon // Acid Rain Tier 3 : CalamityMod.Instance.GetMusicFromMusicMod("AcidRain1") ?? MusicID.OldOnesArmy; // Acid Rain Tier 1 + 2 } diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index 34d6cfbf95..e346d98659 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -42,7 +42,6 @@ namespace CalamityMod.ILEditing IL.Terraria.Player.Update_NPCCollision += NerfShieldOfCthulhuBonkSafety; On.Terraria.WorldGen.OpenDoor += OpenDoor_LabDoorOverride; On.Terraria.WorldGen.CloseDoor += CloseDoor_LabDoorOverride; - On.Terraria.Wiring.Teleport += DisableTeleporters; // only applies in boss rush IL.Terraria.Main.DrawInterface_40_InteractItemIcon += MakeMouseHoverItemsSupportAnimations; On.Terraria.Item.AffixName += IncorporateEnchantmentInAffix; On.Terraria.Projectile.NewProjectile_IEntitySource_float_float_float_float_int_int_float_int_float_float += IncorporateMinionExplodingCountdown; @@ -155,7 +154,6 @@ namespace CalamityMod.ILEditing IL.Terraria.Player.Update_NPCCollision -= NerfShieldOfCthulhuBonkSafety; On.Terraria.WorldGen.OpenDoor -= OpenDoor_LabDoorOverride; On.Terraria.WorldGen.CloseDoor -= CloseDoor_LabDoorOverride; - On.Terraria.Wiring.Teleport -= DisableTeleporters; IL.Terraria.Main.DrawInterface_40_InteractItemIcon -= MakeMouseHoverItemsSupportAnimations; On.Terraria.Item.AffixName -= IncorporateEnchantmentInAffix; On.Terraria.Projectile.NewProjectile_IEntitySource_float_float_float_float_int_int_float_int_float_float -= IncorporateMinionExplodingCountdown; diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index afd5c63d00..470fab7d4d 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -449,16 +449,6 @@ namespace CalamityMod.ILEditing } #endregion Platform Collision Checks for Grounded Bosses - #region Teleporter Disabling During Boss Fights - private static void DisableTeleporters(On.Terraria.Wiring.orig_Teleport orig) - { - if (CalamityPlayer.areThereAnyDamnBosses) - return; - - orig(); - } - #endregion Teleporter Disabling During Boss Fights - #region Incorporate Enchantments in Item Names private static string IncorporateEnchantmentInAffix(On.Terraria.Item.orig_AffixName orig, Item self) { diff --git a/Items/Accessories/AsgardsValor.cs b/Items/Accessories/AsgardsValor.cs index 10996da30b..b541626398 100644 --- a/Items/Accessories/AsgardsValor.cs +++ b/Items/Accessories/AsgardsValor.cs @@ -66,7 +66,6 @@ namespace CalamityMod.Items.Accessories AddIngredient(). AddIngredient(). AddIngredient(). - AddIngredient(ItemID.LifeFruit, 5). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Accessories/ScuttlersJewel.cs b/Items/Accessories/ScuttlersJewel.cs index ef222e6f7c..da1346fd49 100644 --- a/Items/Accessories/ScuttlersJewel.cs +++ b/Items/Accessories/ScuttlersJewel.cs @@ -11,7 +11,9 @@ namespace CalamityMod.Items.Accessories { SacrificeTotal = 1; DisplayName.SetDefault("Scuttler's Jewel"); - Tooltip.SetDefault("Stealth strike projectiles spawn a jewel spike when destroyed"); + Tooltip.SetDefault("Stealth strike projectiles spawn a jewel spike when destroyed\n" + + "Can also be broken down at an extractinator"); + ItemID.Sets.ExtractinatorMode[Item.type] = Item.type; } public override void SetDefaults() @@ -21,6 +23,12 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.Rarity1BuyPrice; Item.rare = ItemRarityID.Blue; Item.accessory = true; + + Item.useStyle = ItemUseStyleID.HiddenAnimation; + Item.useAnimation = 10; + Item.useTime = 2; + Item.consumable = true; + } public override void UpdateAccessory(Player player, bool hideVisual) @@ -28,5 +36,26 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.scuttlersJewel = true; } + + public override void ExtractinatorUse(ref int resultType, ref int resultStack) + { + float dropRand = Main.rand.Next(1, 8); + resultStack = Main.rand.Next(1, 3); + + if (dropRand == 1f) + resultType = ItemID.Ruby; + else if (dropRand == 2f) + resultType = ItemID.Diamond; + else if (dropRand == 3f) + resultType = ItemID.Emerald; + else if (dropRand == 4f) + resultType = ItemID.Topaz; + else if (dropRand == 5f) + resultType = ItemID.Sapphire; + else if (dropRand == 6f) + resultType = ItemID.Amethyst; + else if (dropRand >= 7f) + resultType = ItemID.Amber; + } } } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 2eb2f3a110..daea946679 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -889,10 +889,6 @@ namespace CalamityMod.Items { return false; } - if (item.type == ItemID.MagicMirror || item.type == ItemID.IceMirror || item.type == ItemID.CellPhone || item.type == ItemID.RecallPotion) - { - return !player.HasBuff(ModContent.BuffType()); - } if (item.type == ItemID.RodofDiscord) { if (player.chaosState) diff --git a/Items/CalamityGlobalItemLoot.cs b/Items/CalamityGlobalItemLoot.cs index 6dfeeb2ace..20b92d2a15 100644 --- a/Items/CalamityGlobalItemLoot.cs +++ b/Items/CalamityGlobalItemLoot.cs @@ -291,9 +291,9 @@ namespace CalamityMod.Items case ItemID.HallowedFishingCrate: case ItemID.HallowedFishingCrateHard: BlockCrateDrops(); - int potion = WorldGen.crimson ? ModContent.ItemType() : ModContent.ItemType(); DropHelper.DropItemCondition(s, player, ModContent.ItemType(), DownedBossSystem.downedProvidence, 0.15f, 5, 10); - DropHelper.DropItemCondition(s, player, potion, DownedBossSystem.downedProvidence, 0.1f, 1, 2); + DropHelper.DropItemCondition(s, player, ModContent.ItemType(), DownedBossSystem.downedProvidence, 0.15f, 1, 2); + DropHelper.DropItemCondition(s, player, ModContent.ItemType(), DownedBossSystem.downedProvidence, 0.15f, 1, 2); break; case ItemID.DungeonFishingCrate: diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 94ce4658d6..d04fd550e2 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -255,20 +255,10 @@ namespace CalamityMod.Items if (item.type == ItemID.GelBalloon) EditTooltipByNum(0, (line) => line.Text = ""); - // Teleporters not working while a boss is alive. - if (item.type == ItemID.Teleporter) - EditTooltipByName("Placeable", (line) => line.Text += "\nCannot be used while a boss is alive"); - // Flesh Knuckles giving extra max life. if (item.type == ItemID.FleshKnuckles || item.type == ItemID.HeroShield || item.type == ItemID.BerserkerGlove) EditTooltipByNum(0, (line) => line.Text += "\nMax life increased by 45"); - // Mirrors and Recall Potions cannot be used while a boss is alive. - if (item.type == ItemID.MagicMirror || item.type == ItemID.IceMirror || item.type == ItemID.CellPhone || item.type == ItemID.RecallPotion) - ApplyTooltipEdits(tooltips, - (i, l) => l.Mod == "Terraria" && l.Name == (i.type == ItemID.CellPhone ? "Tooltip1" : "Tooltip0"), - (line) => line.Text += "\nCannot be used while you have the Boss Effects buff"); - // Rod of Discord cannot be used multiple times to hurt yourself if (item.type == ItemID.RodofDiscord) EditTooltipByNum(0, (line) => line.Text += "\nTeleportation is disabled while Chaos State is active"); diff --git a/Items/Weapons/Magic/RainbowPartyCannon.cs b/Items/Weapons/Magic/RainbowPartyCannon.cs index 86d3bb1393..797c6b6c29 100644 --- a/Items/Weapons/Magic/RainbowPartyCannon.cs +++ b/Items/Weapons/Magic/RainbowPartyCannon.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Items.Weapons.Magic CreateRecipe(). AddIngredient(ItemID.ConfettiCannon). AddIngredient(). - AddIngredient(ItemID.FireworksLauncher). + AddIngredient(ItemID.Celeb2). AddIngredient(ItemID.FlaskofParty, 5). AddIngredient(ItemID.SoulofLight, 25). AddIngredient(ItemID.Confetti, 50). diff --git a/Items/Weapons/Ranged/Pumpler.cs b/Items/Weapons/Ranged/Pumpler.cs index 4e4f32d5fc..1d6df97dcb 100644 --- a/Items/Weapons/Ranged/Pumpler.cs +++ b/Items/Weapons/Ranged/Pumpler.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - Item.damage = 27; + Item.damage = 18; Item.DamageType = DamageClass.Ranged; Item.width = 72; Item.height = 34; diff --git a/Items/Weapons/Summon/HauntedScroll.cs b/Items/Weapons/Summon/HauntedScroll.cs index b853f1cd3b..4fa5ced0c4 100644 --- a/Items/Weapons/Summon/HauntedScroll.cs +++ b/Items/Weapons/Summon/HauntedScroll.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Summon AddIngredient(ItemID.Wood, 10). AddIngredient(ItemID.SoulofLight, 5). AddIngredient(ItemID.SoulofNight, 5). - AddIngredient(ItemID.Bowl). + AddIngredient(ItemID.FoodPlatter, 3). AddTile(TileID.Anvils). Register(); } diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 29c5164af7..cd3cb8fbe5 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -406,15 +406,17 @@ namespace CalamityMod.NPCs #endregion #region Blood Moon - // Drippler - // Bouncing Eyeball @ 2.5% Normal, 5% Expert+ - case NPCID.Drippler: - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 40, 20)); - break; // All Blood Moon fishing enemies // Drop more Blood Orbs @ 100% + + // Wandering Eye Fish + // Bouncing Eyeball @ 10% Normal, 16.66% Expert+ case NPCID.EyeballFlyingFish: + npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 10, 6)); + npcLoot.Add(ModContent.ItemType(), 1, 3, 6); + break; + case NPCID.ZombieMerman: npcLoot.Add(ModContent.ItemType(), 1, 3, 6); break; diff --git a/NPCs/NormalNPCs/CrawlerAmber.cs b/NPCs/NormalNPCs/CrawlerAmber.cs index 9d46f015e6..c77631eae0 100644 --- a/NPCs/NormalNPCs/CrawlerAmber.cs +++ b/NPCs/NormalNPCs/CrawlerAmber.cs @@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.Amber, 1, 2, 4); - npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ModContent.ItemType(), 6); } } } diff --git a/NPCs/NormalNPCs/CrawlerAmethyst.cs b/NPCs/NormalNPCs/CrawlerAmethyst.cs index 3012bd9458..98a00c4e28 100644 --- a/NPCs/NormalNPCs/CrawlerAmethyst.cs +++ b/NPCs/NormalNPCs/CrawlerAmethyst.cs @@ -118,7 +118,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.Amethyst, 1, 2, 4); - npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ModContent.ItemType(), 6); } } } diff --git a/NPCs/NormalNPCs/CrawlerCrystal.cs b/NPCs/NormalNPCs/CrawlerCrystal.cs index e327fe0f36..6ebc72b49f 100644 --- a/NPCs/NormalNPCs/CrawlerCrystal.cs +++ b/NPCs/NormalNPCs/CrawlerCrystal.cs @@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.CrystalShard, 1, 2, 4); - npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ModContent.ItemType(), 6); } } } diff --git a/NPCs/NormalNPCs/CrawlerDiamond.cs b/NPCs/NormalNPCs/CrawlerDiamond.cs index 98fc0c2f8f..dfa2e03f30 100644 --- a/NPCs/NormalNPCs/CrawlerDiamond.cs +++ b/NPCs/NormalNPCs/CrawlerDiamond.cs @@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.Diamond, 1, 2, 4); - npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ModContent.ItemType(), 6); } } } diff --git a/NPCs/NormalNPCs/CrawlerEmerald.cs b/NPCs/NormalNPCs/CrawlerEmerald.cs index 648c4eef98..2a2a54f0b0 100644 --- a/NPCs/NormalNPCs/CrawlerEmerald.cs +++ b/NPCs/NormalNPCs/CrawlerEmerald.cs @@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.Emerald, 1, 2, 4); - npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ModContent.ItemType(), 6); } } } diff --git a/NPCs/NormalNPCs/CrawlerRuby.cs b/NPCs/NormalNPCs/CrawlerRuby.cs index 494366adcc..3cc9ccee11 100644 --- a/NPCs/NormalNPCs/CrawlerRuby.cs +++ b/NPCs/NormalNPCs/CrawlerRuby.cs @@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.Ruby, 1, 2, 4); - npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ModContent.ItemType(), 6); } } } diff --git a/NPCs/NormalNPCs/CrawlerSapphire.cs b/NPCs/NormalNPCs/CrawlerSapphire.cs index d0723eef1d..0b4f932123 100644 --- a/NPCs/NormalNPCs/CrawlerSapphire.cs +++ b/NPCs/NormalNPCs/CrawlerSapphire.cs @@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.Sapphire, 1, 2, 4); - npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ModContent.ItemType(), 6); } } } diff --git a/NPCs/NormalNPCs/CrawlerTopaz.cs b/NPCs/NormalNPCs/CrawlerTopaz.cs index af8d756449..9bb26400e1 100644 --- a/NPCs/NormalNPCs/CrawlerTopaz.cs +++ b/NPCs/NormalNPCs/CrawlerTopaz.cs @@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.Topaz, 1, 2, 4); - npcLoot.Add(ModContent.ItemType(), 10); + npcLoot.Add(ModContent.ItemType(), 6); } } } diff --git a/Projectiles/Melee/CnidarianJellyfishOnTheString.cs b/Projectiles/Melee/CnidarianJellyfishOnTheString.cs index e9c46c5ae5..7057dad097 100644 --- a/Projectiles/Melee/CnidarianJellyfishOnTheString.cs +++ b/Projectiles/Melee/CnidarianJellyfishOnTheString.cs @@ -40,9 +40,6 @@ namespace CalamityMod.Projectiles.Melee public override void SetStaticDefaults() { DisplayName.SetDefault("Cnidarian"); - ProjectileID.Sets.YoyosLifeTimeMultiplier[Projectile.type] = 7f; - ProjectileID.Sets.YoyosMaximumRange[Projectile.type] = 240f; - ProjectileID.Sets.YoyosTopSpeed[Projectile.type] = 11f; } public override void SetDefaults() @@ -64,8 +61,8 @@ namespace CalamityMod.Projectiles.Melee public void SetOrigin(Vector2 position) { Projectile.Center = position; - if ((Projectile.Center - Owner.Center).Length() > 380f) - Projectile.Center = Owner.Center + (Projectile.Center - Owner.Center).SafeNormalize(Vector2.One) * 380f; + if ((Projectile.Center - Owner.Center).Length() > 380f * Owner.whipRangeMultiplier) + Projectile.Center = Owner.Center + (Projectile.Center - Owner.Center).SafeNormalize(Vector2.One) * 380f * Owner.whipRangeMultiplier; } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) diff --git a/Projectiles/Ranged/PumplerGrenade.cs b/Projectiles/Ranged/PumplerGrenade.cs index d5754f4532..8f46a6cb44 100644 --- a/Projectiles/Ranged/PumplerGrenade.cs +++ b/Projectiles/Ranged/PumplerGrenade.cs @@ -3,11 +3,16 @@ using Terraria; using Terraria.ModLoader; using Terraria.ID; using Terraria.Audio; +using CalamityMod.Particles; +using System; namespace CalamityMod.Projectiles.Ranged { public class PumplerGrenade : ModProjectile { + public ref float State => ref Projectile.ai[0]; + public static int MaxTime => 180; + public override void SetStaticDefaults() { DisplayName.SetDefault("Squash Shell"); @@ -15,63 +20,123 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - Projectile.width = 16; - Projectile.height = 22; + Projectile.width = 26; + Projectile.height = 26; Projectile.friendly = true; - Projectile.timeLeft = 180; - Projectile.penetrate = 1; + Projectile.timeLeft = MaxTime; + Projectile.penetrate = -1; Projectile.DamageType = DamageClass.Ranged; Projectile.ignoreWater = true; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 20; + } public override string Texture => "CalamityMod/Projectiles/Ranged/PumplerGrenade"; private void Explode(bool NPCHit = false) { SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - if (Main.myPlayer == Projectile.owner) - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage), Projectile.knockBack, Projectile.owner, NPCHit ? 1 : 0); - } - Projectile.Kill(); + + int size = NPCHit ? 50 : 70; //Bigger explosion if no npc is hit + Projectile.scale = (size / (float)Projectile.height) * Projectile.scale; + + Projectile.position -= Vector2.One * (size - Projectile.width) * 0.5f; + Projectile.height = Projectile.width = size; + + Projectile.tileCollide = false; + Projectile.timeLeft = 6; + Projectile.hide = true; + Projectile.velocity = Vector2.Zero; + State = 1; } public override void AI() { - if (Projectile.timeLeft == 1) - Explode(); - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Point tileCoords = Projectile.Bottom.ToTileCoordinates(); - if (Main.tile[tileCoords.X, tileCoords.Y + 1].HasUnactuatedTile && - WorldGen.SolidTile(Main.tile[tileCoords.X, tileCoords.Y + 1]) && Projectile.timeLeft < 165) + //Behave like a grenade + if (State == 0) { - Explode(); - Projectile.Kill(); + if (Projectile.timeLeft == 1) + { + Explode(); + return; + } + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + Point tileCoords = Projectile.Bottom.ToTileCoordinates(); + if (Main.tile[tileCoords.X, tileCoords.Y + 1].HasUnactuatedTile && + WorldGen.SolidTile(Main.tile[tileCoords.X, tileCoords.Y + 1]) && Projectile.timeLeft < 165) + { + Explode(); + return; + } + + else if (Projectile.timeLeft < MaxTime - 8) + { + Projectile.velocity.Y += 0.4f; + if (Projectile.velocity.Y > 16f) + Projectile.velocity.Y = 16f; + } } + else { - Projectile.velocity.Y += 0.4f; - if (Projectile.velocity.Y > 16f) - Projectile.velocity.Y = 16f; + if (Projectile.timeLeft == 5) + SmokeBoom(); } } + + private void SmokeBoom() + { + for (int i = 0; i < 15; i++) + { + Particle smoke = new SmallSmokeParticle(Projectile.Center + Main.rand.NextVector2Circular(15f, 15f), Vector2.Zero, Color.Orange, new Color(40, 40, 40), Main.rand.NextFloat(0.8f, 1.6f), 145 - Main.rand.Next(30)); + smoke.Velocity = (smoke.Position - Projectile.Center) * 0.2f + Projectile.velocity; + GeneralParticleHandler.SpawnParticle(smoke); + } + } + public override bool OnTileCollide(Vector2 oldVelocity) { Projectile.velocity *= -1f; return false; } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - Explode(true); + if (State == 0) + { + SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); + Explode(true); + } } - public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + public override bool? CanHitNPC(NPC target) { - //Damage gets lowered for the main hit, most of the damage comes from the explosion itself. - damage = (int)(damage * 0.1f); + if (State == 0) + return null; + + float blastRadius = Projectile.height / 2f; + + //Get the absolute value of the distance between the target's hitbox center & the explosion's center + float distanceX = Math.Abs(Projectile.Center.X - target.Hitbox.Center.X); + float distanceY = Math.Abs(Projectile.Center.Y - target.Hitbox.Center.Y); + + //If the distance is just too big for the two to intersect, return false + if (distanceX > (target.Hitbox.Width / 2f + blastRadius) || distanceY > (target.Hitbox.Height / 2f + blastRadius)) + return false; + + //If either distance is too small (aka if the projectile's center is inside of the target's hitbox, return true + if (distanceX <= (target.Hitbox.Width / 2f) || distanceY <= (target.Hitbox.Height / 2f)) + return null; + + //Pythagorean theorem stuff to determine the litteral edge cases + float squaredCornerDisance = (float)(Math.Pow(distanceX - target.Hitbox.Width / 2f, 2) + Math.Pow(distanceY - target.Hitbox.Height / 2f, 2)); + if (squaredCornerDisance <= Math.Pow(blastRadius, 2)) + return null; + + return false; } } } diff --git a/Projectiles/Ranged/PumplerGrenadeExplosion.cs b/Projectiles/Ranged/PumplerGrenadeExplosion.cs deleted file mode 100644 index 42ae940ae8..0000000000 --- a/Projectiles/Ranged/PumplerGrenadeExplosion.cs +++ /dev/null @@ -1,75 +0,0 @@ -using Microsoft.Xna.Framework; -using System; -using Terraria; -using Terraria.ModLoader; -using CalamityMod.Particles; - -namespace CalamityMod.Projectiles.Ranged -{ - public class PumplerGrenadeExplosion : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - private bool NPCHit => Projectile.ai[0] == 1; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cucurbitace Blast"); - } - - public override void SetDefaults() - { - Projectile.width = 70; - Projectile.height = 70; - Projectile.friendly = true; - Projectile.timeLeft = 5; - Projectile.penetrate = -1; - Projectile.DamageType = DamageClass.Ranged; - Projectile.ignoreWater = true; - } - - private void SmokeBoom() - { - for (int i = 0; i < 15; i++) - { - Particle smoke = new SmallSmokeParticle(Projectile.Center + Main.rand.NextVector2Circular(15f, 15f), Vector2.Zero, Color.Orange, new Color(40, 40, 40), Main.rand.NextFloat(0.8f, 1.6f), 145 - Main.rand.Next(30)); - smoke.Velocity = (smoke.Position - Projectile.Center) * 0.2f + Projectile.velocity; - GeneralParticleHandler.SpawnParticle(smoke); - } - } - - public override bool? CanHitNPC(NPC target) - { - float blastRadius = Projectile.height / 2f; - - //Get the absolute value of the distance between the target's hitbox center & the explosion's center - float distanceX = Math.Abs(Projectile.Center.X - target.Hitbox.Center.X); - float distanceY = Math.Abs(Projectile.Center.Y - target.Hitbox.Center.Y); - - //If the distance is just too big for the two to intersect, return false - if (distanceX > (target.Hitbox.Width / 2f + blastRadius) || distanceY > (target.Hitbox.Height / 2f + blastRadius)) - return false; - - //If either distance is too small (aka if the projectile's center is inside of the target's hitbox, return true - if (distanceX <= (target.Hitbox.Width / 2f) || distanceY <= (target.Hitbox.Height / 2f)) - return true; - - //Pythagorean theorem stuff to determine the litteral edge cases - float squaredCornerDisance = (float)(Math.Pow(distanceX - target.Hitbox.Width / 2f, 2) + Math.Pow(distanceY - target.Hitbox.Height / 2f, 2)); - return (squaredCornerDisance <= Math.Pow(blastRadius, 2)); - } - - public override void AI() - { - //Bigger explosion if no npc gets hit - if (!NPCHit) - { - Projectile.width = 120; - Projectile.height = 120; - } - - if (Projectile.timeLeft == 5) - SmokeBoom(); - } - } -}