Mechworm loses segments instead of dying when a minion slot is lost
This commit is contained in:
1 parent
87f051f42e
commit
37c1dc7a2b
4 files changed
+22
-54
No files matched your search
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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<Mechworm>(), 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)
|
||||
{
|
||||
|
||||
@@ -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<MechwormHead>())
|
||||
{
|
||||
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<MechwormHead>() ||
|
||||
Main.projectile[byUUID].type == ModContent.ProjectileType<MechwormBody>() ||
|
||||
Main.projectile[byUUID].type == ModContent.ProjectileType<MechwormBody2>()))
|
||||
|
||||
Reference in new issue
Block a user