diff --git a/Projectiles/Summon/MechwormBody.cs b/Projectiles/Summon/MechwormBody.cs index 8f4b173ffc..5c9a8e48a9 100644 --- a/Projectiles/Summon/MechwormBody.cs +++ b/Projectiles/Summon/MechwormBody.cs @@ -9,9 +9,6 @@ namespace CalamityMod.Projectiles.Summon { public class MechwormBody : ModProjectile { - private int playerMinionSlots = 0; - private bool runCheck = true; - public override void SetStaticDefaults() { DisplayName.SetDefault("Mechworm"); @@ -40,25 +37,11 @@ namespace CalamityMod.Projectiles.Summon { Lighting.AddLight((int)((projectile.position.X + (float)(projectile.width / 2)) / 16f), (int)((projectile.position.Y + (float)(projectile.height / 2)) / 16f), 0.15f, 0.01f, 0.15f); Player player9 = Main.player[projectile.owner]; - if (player9.maxMinions > playerMinionSlots) - { - playerMinionSlots = player9.maxMinions; - } - if (runCheck) - { - runCheck = false; - playerMinionSlots = player9.maxMinions; - } CalamityPlayer modPlayer = player9.Calamity(); if ((int)Main.time % 120 == 0) { projectile.netUpdate = true; } - if (!player9.active || player9.maxMinions < playerMinionSlots) - { - projectile.active = false; - return; - } int num1051 = 10; if (player9.dead) { diff --git a/Projectiles/Summon/MechwormBody2.cs b/Projectiles/Summon/MechwormBody2.cs index 13d9371b4e..6b30adefa0 100644 --- a/Projectiles/Summon/MechwormBody2.cs +++ b/Projectiles/Summon/MechwormBody2.cs @@ -9,9 +9,6 @@ namespace CalamityMod.Projectiles.Summon { public class MechwormBody2 : ModProjectile { - private int playerMinionSlots = 0; - private bool runCheck = true; - public override void SetStaticDefaults() { DisplayName.SetDefault("Mechworm"); @@ -40,25 +37,11 @@ namespace CalamityMod.Projectiles.Summon { Lighting.AddLight((int)((projectile.position.X + (float)(projectile.width / 2)) / 16f), (int)((projectile.position.Y + (float)(projectile.height / 2)) / 16f), 0.15f, 0.01f, 0.15f); Player player9 = Main.player[projectile.owner]; - if (player9.maxMinions > playerMinionSlots) - { - playerMinionSlots = player9.maxMinions; - } - if (runCheck) - { - runCheck = false; - playerMinionSlots = player9.maxMinions; - } CalamityPlayer modPlayer = player9.Calamity(); if ((int)Main.time % 120 == 0) { projectile.netUpdate = true; } - if (!player9.active || player9.maxMinions < playerMinionSlots) - { - projectile.active = false; - return; - } int num1051 = 10; if (player9.dead) { diff --git a/Projectiles/Summon/MechwormHead.cs b/Projectiles/Summon/MechwormHead.cs index aeb975b2ce..94229ff581 100644 --- a/Projectiles/Summon/MechwormHead.cs +++ b/Projectiles/Summon/MechwormHead.cs @@ -11,9 +11,6 @@ namespace CalamityMod.Projectiles.Summon public class MechwormHead : ModProjectile { private int dust = 3; - private int playerMinionSlots = 0; - private bool runCheck = true; - public override void SetStaticDefaults() { DisplayName.SetDefault("Mechworm"); @@ -54,26 +51,12 @@ namespace CalamityMod.Projectiles.Summon } dust--; } - if (player9.maxMinions > playerMinionSlots) - { - playerMinionSlots = player9.maxMinions; - } - if (runCheck) - { - runCheck = false; - playerMinionSlots = player9.maxMinions; - } CalamityPlayer modPlayer = player9.Calamity(); player9.AddBuff(ModContent.BuffType(), 3600); if ((int)Main.time % 120 == 0) { projectile.netUpdate = true; } - if (!player9.active || player9.maxMinions < playerMinionSlots) - { - projectile.active = false; - return; - } int num1051 = 30; if (player9.dead) { diff --git a/Projectiles/Summon/MechwormTail.cs b/Projectiles/Summon/MechwormTail.cs index 3684de995d..a1a56f8c25 100644 --- a/Projectiles/Summon/MechwormTail.cs +++ b/Projectiles/Summon/MechwormTail.cs @@ -54,10 +54,30 @@ namespace CalamityMod.Projectiles.Summon { projectile.netUpdate = true; } + int byUUID = Projectile.GetByUUID(projectile.owner, (int)projectile.ai[0]); if (!player9.active || player9.maxMinions < playerMinionSlots) { - projectile.active = false; - return; + int lostSlots = playerMinionSlots - player9.maxMinions; + while (lostSlots > 0) + { + Projectile ahead = Main.projectile[byUUID]; + // Each body slot is actually 0.5 slots. Kill two segments to lose 1 "true" slot. + for (int i = 0; i < 2; i++) + { + if (ahead.type != ModContent.ProjectileType()) + { + projectile.localAI[1] = ahead.localAI[1]; + } + projectile.ai[0] = ahead.ai[0]; + projectile.ai[1] = 1f; + projectile.netUpdate = true; + ahead.Kill(); + byUUID = Projectile.GetByUUID(projectile.owner, (int)projectile.ai[0]); + ahead = Main.projectile[byUUID]; + } + lostSlots--; + } + playerMinionSlots = player9.maxMinions; } int num1051 = 10; if (player9.dead) @@ -77,7 +97,6 @@ namespace CalamityMod.Projectiles.Summon float num1064; float scaleFactor17; float scaleFactor18; - int byUUID = Projectile.GetByUUID(projectile.owner, (int)projectile.ai[0]); if (byUUID >= 0 && Main.projectile[byUUID].active && (Main.projectile[byUUID].type == ModContent.ProjectileType() || Main.projectile[byUUID].type == ModContent.ProjectileType() || Main.projectile[byUUID].type == ModContent.ProjectileType()))