From 8d4d329f5ac90fa1ea2828b92e62ee7afde1889a Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:17:41 +0700 Subject: [PATCH] More Atlas Munitions changes the held cannon can no longer just fall down platforms stupid bugfix #6 --- Projectiles/Summon/AtlasMunitionsAutocannon.cs | 1 + Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Projectiles/Summon/AtlasMunitionsAutocannon.cs b/Projectiles/Summon/AtlasMunitionsAutocannon.cs index 44450ba507..d01046351f 100644 --- a/Projectiles/Summon/AtlasMunitionsAutocannon.cs +++ b/Projectiles/Summon/AtlasMunitionsAutocannon.cs @@ -189,6 +189,7 @@ namespace CalamityMod.Projectiles.Summon Projectile heldCannon = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Main.LocalPlayer.Center, Vector2.UnitX, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Main.myPlayer); heldCannon.ModProjectile().HeatInterpolant = HeatInterpolant * 0.65f; heldCannon.originalDamage = Projectile.originalDamage; + heldCannon.ai[2] = Projectile.ai[2]; CannonIsMounted = false; Projectile.netUpdate = true; diff --git a/Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs b/Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs index ea50058069..64a475442a 100644 --- a/Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs +++ b/Projectiles/Summon/AtlasMunitionsAutocannonHeld.cs @@ -192,6 +192,11 @@ namespace CalamityMod.Projectiles.Summon Projectile.owner = Main.myPlayer; Projectile.netUpdate = true; } + + // Destroy the cannon if the pod (base sentry) got replaced by other sentries + Projectile parent = Main.projectile[(int)Projectile.ai[2]]; + if (parent.type != ModContent.ProjectileType() || !parent.active) + Projectile.Kill(); } public void DetermineFrames() @@ -328,6 +333,12 @@ namespace CalamityMod.Projectiles.Summon // The cannon does not get destroyed by tile collisions. This only applies when in the dropped state. public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + fallThrough = false; + return true; + } + // The cannon itself does not do damage, but it does store damage for the lasers that it fires. public override bool? CanDamage() => false; }