Hopefully fixed Brimseeker aura problems in MP
This commit is contained in:
1 parent
4f40ae6b73
commit
637898e2b7
3 files changed
+23
-9
No files matched your search
@@ -6,10 +6,10 @@ using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
namespace CalamityMod.Projectiles.Summon
|
||||
{
|
||||
public class BrimseekerAuraBall : ModProjectile
|
||||
public class BrimseekerAuraBall : ModProjectile
|
||||
{
|
||||
public bool Initialized = false;
|
||||
public Projectile ParentProjectile => Main.projectile[(int)projectile.ai[0]];
|
||||
public Projectile ParentProjectile => CalamityUtils.FindProjectileByIdentity((int)projectile.ai[0], projectile.owner);
|
||||
public float Outwardness
|
||||
{
|
||||
get => projectile.localAI[0];
|
||||
@@ -49,9 +49,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
Initialized = true;
|
||||
}
|
||||
|
||||
Projectile ParentProjectile = Main.projectile[(int)projectile.ai[0]];
|
||||
|
||||
if (!ParentProjectile.active)
|
||||
if (ParentProjectile is null)
|
||||
{
|
||||
projectile.Kill();
|
||||
return;
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
if (Main.rand.NextBool(360))
|
||||
dust.scale = 1.5f;
|
||||
}
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
{
|
||||
if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType<DormantBrimseekerBab>() &&
|
||||
Main.projectile[i].owner == projectile.owner && Main.projectile[i].localAI[1] == 0f)
|
||||
@@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
for (int j = 0; j < 30; j++)
|
||||
{
|
||||
Dust dust = Dust.NewDustPerfect(Main.projectile[i].Center, (int)CalamityDusts.Brimstone);
|
||||
dust.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * 7f;
|
||||
dust.velocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * 7f;
|
||||
}
|
||||
Main.projectile[i].localAI[1] = 1f;
|
||||
Main.PlaySound(SoundID.Item45, Main.projectile[i].Center);
|
||||
@@ -89,12 +89,12 @@ namespace CalamityMod.Projectiles.Summon
|
||||
|
||||
if (Main.rand.NextBool(50))
|
||||
{
|
||||
int idx = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType<BrimseekerAuraBall>(), projectile.damage, 3f, projectile.owner, projectile.whoAmI);
|
||||
int idx = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType<BrimseekerAuraBall>(), projectile.damage, 3f, projectile.owner, projectile.identity);
|
||||
Main.projectile[idx].timeLeft = projectile.timeLeft;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int i = 0; i < Main.projectile.Length; i++)
|
||||
|
||||
@@ -26,6 +26,22 @@ namespace CalamityMod
|
||||
return projectile.modProjectile as T;
|
||||
}
|
||||
|
||||
public static Projectile FindProjectileByIdentity(int identity, int ownerIndex)
|
||||
{
|
||||
// If in singleplayer, simply return the projectile at the designated index, as singleplayer will never have mismatching indices.
|
||||
if (Main.netMode == NetmodeID.SinglePlayer)
|
||||
return Main.projectile[identity];
|
||||
|
||||
for (int i = 0; i < Main.maxProjectiles; i++)
|
||||
{
|
||||
if (Main.projectile[i].identity != identity || Main.projectile[i].owner != ownerIndex || !Main.projectile[i].active)
|
||||
continue;
|
||||
|
||||
return Main.projectile[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void KillAllHostileProjectiles()
|
||||
{
|
||||
for (int x = 0; x < Main.maxProjectiles; x++)
|
||||
|
||||
Reference in new issue
Block a user