diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BatAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BatAI.cs
index dca24249e1..13c795c358 100644
--- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BatAI.cs
+++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/BatAI.cs
@@ -284,12 +284,14 @@ public static partial class RevengeanceAndDeathAI
int type = ProjectileID.HarpyFeather;
Vector2 featherVelocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * (CalamityWorld.death ? 4f : 6f);
- int feather = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, featherVelocity, type, damage, 0f, Main.myPlayer);
+ int feather = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), NPC.Center, featherVelocity, type, damage, 0f, Main.myPlayer).identity;
Main.projectile[feather].timeLeft = 300;
if (CalamityWorld.death)
{
- Main.projectile[feather].extraUpdates += 1;
+ Main.projectile[feather].Calamity().extraUpdatesToSync = 1;
Main.projectile[feather].timeLeft = 600;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, feather);
}
}
}
@@ -316,12 +318,14 @@ public static partial class RevengeanceAndDeathAI
int type = ProjectileID.DemonSickle;
Vector2 sickleVelocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center) * (CalamityWorld.death ? 0.15f : 0.2f);
- int sickle = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, sickleVelocity, type, damage, 0f, Main.myPlayer);
+ int sickle = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), NPC.Center, sickleVelocity, type, damage, 0f, Main.myPlayer).identity;
Main.projectile[sickle].timeLeft = 300;
if (CalamityWorld.death)
{
- Main.projectile[sickle].extraUpdates += 1;
+ Main.projectile[sickle].Calamity().extraUpdatesToSync = 1;
Main.projectile[sickle].timeLeft = 600;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, sickle);
}
}
}
@@ -352,12 +356,14 @@ public static partial class RevengeanceAndDeathAI
int damage = 80;
int type = ProjectileID.UnholyTridentHostile;
- int trident = Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition + tridentVelocity * 100f, tridentVelocity, type, damage, 3f, Main.myPlayer);
+ int trident = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), spawnPosition + tridentVelocity * 100f, tridentVelocity, type, damage, 3f, Main.myPlayer).identity;
Main.projectile[trident].timeLeft = 300;
if (CalamityWorld.death)
{
- Main.projectile[trident].extraUpdates += 1;
+ Main.projectile[trident].Calamity().extraUpdatesToSync = 1;
Main.projectile[trident].timeLeft = 600;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, trident);
}
}
}
diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/CasterAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/CasterAI.cs
index 165932bcf7..fbaff67eb1 100644
--- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/CasterAI.cs
+++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/CasterAI.cs
@@ -296,10 +296,13 @@ public static partial class RevengeanceAndDeathAI
if (canSpawnProj)
{
- int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), (float)(spiritProjSpawnX * 16 + 8), (float)(spiritProjSpawnY * 16 + 8), 0f, 0f, ProjectileID.DesertDjinnCurse, 0, 1f, Main.myPlayer, (float)NPC.target, 0f);
+ int proj = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), new Vector2((float)(spiritProjSpawnX * 16 + 8), (float)(spiritProjSpawnY * 16 + 8)), Vector2.Zero, ProjectileID.DesertDjinnCurse, 0, 1f, Main.myPlayer, (float)NPC.target, 0f).identity;
if (CalamityWorld.death)
- Main.projectile[proj].extraUpdates += 1;
-
+ {
+ Main.projectile[proj].Calamity().extraUpdatesToSync = 1;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj);
+ }
break;
}
}
diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FighterAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FighterAI.cs
index a7378e9b3b..4cd01430ad 100644
--- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FighterAI.cs
+++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FighterAI.cs
@@ -2922,22 +2922,26 @@ PrepareToShoot:
}
else if (npcType == NPCID.StardustSoldier)
{
- int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, distX, distY, projectileType, damage, 0f, Main.myPlayer, 0f, (float)NPC.whoAmI);
+ int proj = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), spawnPosition, new Vector2(distX, distY), projectileType, damage, 0f, Main.myPlayer, 0f, NPC.whoAmI).identity;
if (CalamityWorld.death)
{
- Main.projectile[proj].extraUpdates += 1;
+ Main.projectile[proj].Calamity().extraUpdatesToSync = 1;
Main.projectile[proj].timeLeft = 480;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj);
}
}
else if (npcType == NPCID.NebulaSoldier)
{
for (int i = 0; i < 4; i++)
{
- int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X - (float)(NPC.spriteDirection * 4), NPC.Center.Y + 6f, (float)(-3 + 2 * i) * 0.15f, (float)(-(float)Main.rand.Next(0, 3)) * 0.2f - 0.1f, projectileType, damage, 0f, Main.myPlayer, 0f, (float)NPC.whoAmI);
+ int proj = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), new Vector2(NPC.Center.X - (float)(NPC.spriteDirection * 4), NPC.Center.Y + 6f), new Vector2((float)(-3 + 2 * i) * 0.15f, (float)(-(float)Main.rand.Next(0, 3)) * 0.2f - 0.1f), projectileType, damage, 0f, Main.myPlayer, 0f, (float)NPC.whoAmI).identity;
if (CalamityWorld.death)
{
- Main.projectile[proj].extraUpdates += 1;
+ Main.projectile[proj].Calamity().extraUpdatesToSync = 1;
Main.projectile[proj].timeLeft = 1200;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj);
}
}
}
@@ -2948,11 +2952,13 @@ PrepareToShoot:
}
else
{
- int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, distX, distY, projectileType, damage, 0f, Main.myPlayer);
+ int proj = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), spawnPosition, new Vector2(distX, distY), projectileType, damage, 0f, Main.myPlayer).identity;
if (CalamityWorld.death)
{
- Main.projectile[proj].extraUpdates += 1;
+ Main.projectile[proj].Calamity().extraUpdatesToSync = 1;
Main.projectile[proj].timeLeft = 1200;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj);
}
}
}
@@ -3192,12 +3198,14 @@ PrepareToShoot:
{
int velocityX = 3 * NPC.direction;
int velocityY = -5;
- int clownBomb = Projectile.NewProjectile(NPC.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, velocityX, velocityY, ProjectileID.HappyBomb, 0, 0f, Main.myPlayer, 0f, 0f);
+ int clownBomb = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), spawnPosition, new Vector2(velocityX, velocityY), ProjectileID.HappyBomb, 0, 0f, Main.myPlayer, 0f, 0f).identity;
Main.projectile[clownBomb].timeLeft = 300;
if (CalamityWorld.death)
{
- Main.projectile[clownBomb].extraUpdates += 1;
+ Main.projectile[clownBomb].Calamity().extraUpdatesToSync = 1;
Main.projectile[clownBomb].timeLeft = 600;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, clownBomb);
}
NPC.ai[2] = 0f;
}
diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlowInvaderAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlowInvaderAI.cs
index 6ae95decd4..299d6474a1 100644
--- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlowInvaderAI.cs
+++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlowInvaderAI.cs
@@ -50,8 +50,10 @@ public static partial class RevengeanceAndDeathAI
while (Math.Abs(projDirection.X) < 1.5f)
projDirection = Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * new Vector2(5f, 3f);
- int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, projDirection, ProjectileID.StardustJellyfishSmall, 60, 0f, Main.myPlayer, 0f, NPC.whoAmI);
- Main.projectile[proj].extraUpdates += 1;
+ int proj = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), NPC.Center, projDirection, ProjectileID.StardustJellyfishSmall, 60, 0f, Main.myPlayer, 0f, NPC.whoAmI).identity;
+ Main.projectile[proj].Calamity().extraUpdatesToSync = 1;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj);
}
return false;
diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingAI.cs
index 1c582877aa..d72cb617c5 100644
--- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingAI.cs
+++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeaths/FlyingAI.cs
@@ -598,9 +598,11 @@ public static partial class RevengeanceAndDeathAI
projDamage = (int)(30f * NPC.scale);
int stingerType = ProjectileID.Stinger;
- int stingerSpawn = Projectile.NewProjectile(NPC.GetSource_FromAI(), projSpawnPosition.X, projSpawnPosition.Y, projTargetXDist, projTargetYDist, stingerType, projDamage, 0f, Main.myPlayer);
+ int stingerSpawn = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), projSpawnPosition, new Vector2(projTargetXDist, projTargetYDist), stingerType, projDamage, 0f, Main.myPlayer).identity;
Main.projectile[stingerSpawn].timeLeft = (CalamityWorld.death || Main.hardMode) ? 600 : 300;
- Main.projectile[stingerSpawn].extraUpdates += (CalamityWorld.death || Main.hardMode) ? 1 : 0;
+ Main.projectile[stingerSpawn].Calamity().extraUpdatesToSync = (CalamityWorld.death || Main.hardMode) ? 1 : 0;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, stingerSpawn);
NPC.ai[1] = 301f;
NPC.netUpdate = true;
}
@@ -673,11 +675,13 @@ public static partial class RevengeanceAndDeathAI
NPC.netUpdate = true;
NPC.localAI[0] = 0f;
bloodShotPosition = NPC.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y));
- int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, bloodShotPosition * (CalamityWorld.death ? 6f : 10f), ProjectileID.BloodShot, 50, 1f, Main.myPlayer);
+ int proj = Projectile.NewProjectileDirect(NPC.GetSource_FromAI(), NPC.Center, bloodShotPosition * (CalamityWorld.death ? 6f : 10f), ProjectileID.BloodShot, 50, 1f, Main.myPlayer).identity;
if (CalamityWorld.death)
{
- Main.projectile[proj].extraUpdates += 1;
+ Main.projectile[proj].Calamity().extraUpdatesToSync = 1;
Main.projectile[proj].timeLeft = 1200;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj);
}
}
else
diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/SlimeAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/SlimeAI.cs
index 76ff14d407..1d9f0724a3 100644
--- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/SlimeAI.cs
+++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/SlimeAI.cs
@@ -188,9 +188,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies
spikeShootVelocity *= Main.rand.NextVector2Square(0.75f, 1.25f);
spikeShootVelocity.Normalize();
spikeShootVelocity *= Main.rand.NextFloat(3.5f, 4.5f) * projectileShootSpeedFactor;
- int proj = Projectile.NewProjectile(source, NPC.Center, spikeShootVelocity, projectileShootType, 9, 0f, Main.myPlayer);
+ int proj = Projectile.NewProjectileDirect(source, NPC.Center, spikeShootVelocity, projectileShootType, 9, 0f, Main.myPlayer).identity;
if (CalamityWorld.death)
- Main.projectile[proj].extraUpdates += 1;
+ {
+ Main.projectile[proj].Calamity().extraUpdatesToSync = 1;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj);
+ }
projectileShootCountdown = 30f;
}
@@ -198,11 +202,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies
else
{
Vector2 velocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center - Vector2.UnitY * 100f) * projectileShootSpeedFactor * (CalamityWorld.death ? 3.25f : CalamityWorld.revenge ? 5.5f : 4.5f);
- int proj = Projectile.NewProjectile(source, NPC.Center, velocity, projectileShootType, 9, 0f, Main.myPlayer);
+ int proj = Projectile.NewProjectileDirect(source, NPC.Center, velocity, projectileShootType, 9, 0f, Main.myPlayer).identity;
if (CalamityWorld.death)
{
- Main.projectile[proj].extraUpdates += 1;
+ Main.projectile[proj].Calamity().extraUpdatesToSync = 1;
Main.projectile[proj].timeLeft = 1200;
+ if (Main.dedServ)
+ NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj);
}
projectileShootCountdown = 50f;
diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs
index a25e379f13..156eb1dece 100644
--- a/Projectiles/CalamityGlobalProjectile.cs
+++ b/Projectiles/CalamityGlobalProjectile.cs
@@ -93,6 +93,7 @@ namespace CalamityMod.Projectiles
///
* Reducing projectile damage for Hardmode enemies and in Master Mode.
///
* Adding armor penetration to rogue projectiles spawned while wearing Filthy Glove or its upgrades.
///
* Increasing the damage of projectiles from the post-Moon Lord Dungeon, and from the post-DoG Pumpkin Moon, Frost Moon, and Solar Eclipse.
+ ///
* Manually setting the extraUpdates fields of projectiles who use .
///
private bool frameOneHacksExecuted = false;
@@ -225,6 +226,12 @@ namespace CalamityMod.Projectiles
///
public int defExtraUpdates = -1;
+ ///
+ /// Set this to a value higher than one to have a projectile automatically have their extraUpdates field synced across all clients on a server when spawned.
+ /// Please ensure SyncProjectile (or simply is called after setting this.
+ ///
+ public int extraUpdatesToSync = 0;
+
///
/// How many times this projectile has pierced an enemy which applies pierce resist.
/// Used for calculating pierce resist damage reduction.
@@ -437,10 +444,12 @@ namespace CalamityMod.Projectiles
public override void SendExtraAI(Projectile projectile, BitWriter bitWriter, BinaryWriter binaryWriter)
{
binaryWriter.Write(ParentNPCIndex);
+ binaryWriter.Write(extraUpdatesToSync);
}
public override void ReceiveExtraAI(Projectile projectile, BitReader bitReader, BinaryReader binaryReader)
{
ParentNPCIndex = binaryReader.ReadInt32();
+ extraUpdatesToSync = binaryReader.ReadInt32();
}
#endregion On Spawn
@@ -3795,6 +3804,9 @@ namespace CalamityMod.Projectiles
if (!frameOneHacksExecuted)
{
+ if (extraUpdatesToSync > 0)
+ projectile.extraUpdates = extraUpdatesToSync;
+
if (projectile.hostile)
{
// Reduce Nail damage from Nailheads because they're stupid