Fixed a boatload of holdouts not having owner checks for multiplayer

This commit is contained in:
CongratsIsTrash committed 2025-11-22 00:01:58 -05:00
1 parent af0952f5c9
commit 4c045bbda2
10 files changed
+107 -87

No files matched your search

+16 -13
View File
@@ -70,20 +70,23 @@ namespace CalamityMod.Projectiles.Magic
{
SoundEngine.PlaySound(SoundID.Item91, Projectile.Center);
int projID = ModContent.ProjectileType<NanoPurgeLaser>();
float shootSpeed = HeldItem.shootSpeed;
float inaccuracyRatio = 0.045f;
Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.UnitY);
Vector2 perp = shootDirection.RotatedBy(MathHelper.PiOver2);
// Fire a pair of lasers, one with a negative offset, one with a positive offset.
for (int i = -1; i <= 1; i += 2)
if (Main.myPlayer == Projectile.owner)
{
Vector2 spread = Main.rand.NextVector2CircularEdge(shootSpeed, shootSpeed);
Vector2 shootVelocity = shootDirection * shootSpeed + inaccuracyRatio * spread;
Vector2 splitBarrelPos = GunTipPosition + i * LaserOffsetByAnimationFrame[Projectile.frame] * perp;
Projectile.NewProjectile(Projectile.GetSource_FromThis(), splitBarrelPos, shootVelocity, projID, Projectile.damage, Projectile.knockBack, Projectile.owner);
SpawnFiringDust(splitBarrelPos, shootVelocity);
int projID = ModContent.ProjectileType<NanoPurgeLaser>();
float shootSpeed = HeldItem.shootSpeed;
float inaccuracyRatio = 0.045f;
Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.UnitY);
Vector2 perp = shootDirection.RotatedBy(MathHelper.PiOver2);
// Fire a pair of lasers, one with a negative offset, one with a positive offset.
for (int i = -1; i <= 1; i += 2)
{
Vector2 spread = Main.rand.NextVector2CircularEdge(shootSpeed, shootSpeed);
Vector2 shootVelocity = shootDirection * shootSpeed + inaccuracyRatio * spread;
Vector2 splitBarrelPos = GunTipPosition + i * LaserOffsetByAnimationFrame[Projectile.frame] * perp;
Projectile.NewProjectile(Projectile.GetSource_FromThis(), splitBarrelPos, shootVelocity, projID, Projectile.damage, Projectile.knockBack, Projectile.owner);
SpawnFiringDust(splitBarrelPos, shootVelocity);
}
}
}
}
+13 -9
View File
@@ -107,7 +107,8 @@ namespace CalamityMod.Projectiles.Magic
}
Owner.Calamity().GeneralScreenShakePower = 6.5f;
Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3, ModContent.ProjectileType<OmicronBeam>(), Projectile.damage * 32, Projectile.knockBack, Projectile.owner, 0, 0);
if (Main.myPlayer == Projectile.owner)
Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3, ModContent.ProjectileType<OmicronBeam>(), Projectile.damage * 32, Projectile.knockBack, Projectile.owner, 0, 0);
for (int i = 0; i < 8; i++)
{
@@ -120,15 +121,18 @@ namespace CalamityMod.Projectiles.Magic
SoundStyle fire = new("CalamityMod/Sounds/Item/ArcNovaDiffuserBigShot");
SoundEngine.PlaySound(fire with { Volume = 0.2f, Pitch = 0.9f }, Projectile.Center);
for (int i = 0; i < 5; i++)
if (Main.myPlayer == Projectile.owner)
{
firingVelocity3 = (shootDirection * 10).RotatedBy((0.035f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true));
Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType<WingmanShot>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2);
}
for (int i = 0; i < 5; i++)
{
firingVelocity3 = (shootDirection * 10).RotatedBy((-0.035f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true));
Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType<WingmanShot>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2);
for (int i = 0; i < 5; i++)
{
firingVelocity3 = (shootDirection * 10).RotatedBy((0.035f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true));
Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType<WingmanShot>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2);
}
for (int i = 0; i < 5; i++)
{
firingVelocity3 = (shootDirection * 10).RotatedBy((-0.035f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true));
Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType<WingmanShot>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2);
}
}
Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, EffectsColor, new Vector2(1.7f, 0.8f), true);
@@ -47,13 +47,14 @@ namespace CalamityMod.Projectiles.Ranged
{
SoundEngine.PlaySound(SoundID.Item34, Projectile.Center);
Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextFloat() < 0.70f);
for (int i = 0; i < 2; i++)
if (Main.myPlayer == Projectile.owner)
{
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (Projectile.velocity * 10).RotatedByRandom(0.12f), ModContent.ProjectileType<ElementalFire>(), damage, knockback, Projectile.owner);
for (int i = 0; i < 2; i++)
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (Projectile.velocity * 10).RotatedByRandom(0.12f), ModContent.ProjectileType<ElementalFire>(), damage, knockback, Projectile.owner);
}
ShotsFired++;
ShotCooldown = HeldItem.useTime;
if (FireBlobs == 0)
if (FireBlobs == 0 && Main.myPlayer == Projectile.owner)
{
Vector2 newVel = (Projectile.velocity * 9);
Vector2 newPos = GunTipPosition + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 36f;
+14 -11
View File
@@ -72,17 +72,20 @@ namespace CalamityMod.Projectiles.Ranged
break;
}
// Spawns the projectile.
Projectile.NewProjectileDirect(
Projectile.GetSource_FromThis(),
GunTipPosition,
direction * itemShootSpeed,
ProjectileType<FlakKrakenProjectile>(),
itemDamage,
itemKnockback,
Projectile.owner,
rocketTypeShot,
ownerToMouse.Length());
if (Main.myPlayer == Projectile.owner)
{
// Spawns the projectile.
Projectile.NewProjectileDirect(
Projectile.GetSource_FromThis(),
GunTipPosition,
direction * itemShootSpeed,
ProjectileType<FlakKrakenProjectile>(),
itemDamage,
itemKnockback,
Projectile.owner,
rocketTypeShot,
ownerToMouse.Length());
}
// Applies the knockback to the player.
Owner.velocity += ownerToMouse.SafeNormalize(Vector2.UnitY) * -OwnerKnockbackStrength;
+14 -11
View File
@@ -69,17 +69,20 @@ namespace CalamityMod.Projectiles.Ranged
break;
}
// Spawns the projectile.
Projectile.NewProjectileDirect(
Projectile.GetSource_FromThis(),
GunTipPosition,
direction * itemShootSpeed,
ProjectileType<FlakToxicannonProjectile>(),
itemDamage,
itemKnockback,
Projectile.owner,
rocketTypeShot,
ownerToMouse.Length());
if (Main.myPlayer == Projectile.owner)
{
// Spawns the projectile.
Projectile.NewProjectileDirect(
Projectile.GetSource_FromThis(),
GunTipPosition,
direction * itemShootSpeed,
ProjectileType<FlakToxicannonProjectile>(),
itemDamage,
itemKnockback,
Projectile.owner,
rocketTypeShot,
ownerToMouse.Length());
}
// Applies the knockback to the player.
Owner.velocity += ownerToMouse.SafeNormalize(Vector2.UnitY) * -OwnerKnockbackStrength;
+2 -1
View File
@@ -56,7 +56,8 @@ namespace CalamityMod.Projectiles.Ranged
SoundEngine.PlaySound(MagnaCannon.Fire, Projectile.position);
Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed;
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(MathHelper.ToRadians(9f)), ModContent.ProjectileType<MagnaShot>(), Projectile.damage, Projectile.knockBack * (FullyCharged ? 3 : 1), Projectile.owner);
if (Main.myPlayer == Projectile.owner)
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(MathHelper.ToRadians(9f)), ModContent.ProjectileType<MagnaShot>(), Projectile.damage, Projectile.knockBack * (FullyCharged ? 3 : 1), Projectile.owner);
for (int i = 0; i <= 3; i++)
{
Dust dust = Dust.NewDustPerfect(GunTipPosition, 187, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.9f, 1.2f), 0, default, Main.rand.NextFloat(1.5f, 2.3f));
+14 -11
View File
@@ -142,17 +142,20 @@ namespace CalamityMod.Projectiles.Ranged
break;
}
// Spawns the projectile.
Projectile.NewProjectileDirect(
Projectile.GetSource_FromThis(),
GunTipPosition,
projectileVelocity.RotatedByRandom(isRMB ? 0f : MathHelper.PiOver4) * projSpeed * (isRMB ? 1f : Main.rand.NextFloat(0.8f, 1f)),
isRMB ? ProjectileType<ScorpioLargeRocket>() : ProjectileType<ScorpioRocket>(),
damage,
knockback,
Projectile.owner,
rocketType,
projSpeed);
if (Main.myPlayer == Projectile.owner)
{
// Spawns the projectile.
Projectile.NewProjectileDirect(
Projectile.GetSource_FromThis(),
GunTipPosition,
projectileVelocity.RotatedByRandom(isRMB ? 0f : MathHelper.PiOver4) * projSpeed * (isRMB ? 1f : Main.rand.NextFloat(0.8f, 1f)),
isRMB ? ProjectileType<ScorpioLargeRocket>() : ProjectileType<ScorpioRocket>(),
damage,
knockback,
Projectile.owner,
rocketType,
projSpeed);
}
// Inside here go all the things that dedicated servers shouldn't spend resources on.
// Like visuals and sounds.
@@ -83,9 +83,12 @@ namespace CalamityMod.Projectiles.Ranged
SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/MeatySlash"), GunTipPosition);
// Throws a lingering saw at the cursor that deals 3x damage (since the holdout already deals 2x)
float clampedMouseDist = MathHelper.Clamp(Vector2.Distance(GunTipPosition, Owner.Calamity().mouseWorld), 0f, 960f);
float adjustedMouseDist = clampedMouseDist / 21f;
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * adjustedMouseDist, ModContent.ProjectileType<SuperradiantSawLingering>(), (int)(Projectile.damage * 1.5f), Projectile.knockBack, Projectile.owner);
if (Main.myPlayer == Projectile.owner)
{
float clampedMouseDist = MathHelper.Clamp(Vector2.Distance(GunTipPosition, Owner.Calamity().mouseWorld), 0f, 960f);
float adjustedMouseDist = clampedMouseDist / 21f;
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * adjustedMouseDist, ModContent.ProjectileType<SuperradiantSawLingering>(), (int)(Projectile.damage * 1.5f), Projectile.knockBack, Projectile.owner);
}
// Special case: right-clicking while not holding left-click
// This is to keep it friendly to use both fires at the same time, but end the animation early if not
@@ -131,7 +134,8 @@ namespace CalamityMod.Projectiles.Ranged
int sawLevel = (SawPower >= 1f).ToInt() + (SawPower >= 0.25f).ToInt();
// ai[0] determines which slashes are drawn. ai[1] is the saw's timer variable. ai[2] stores the saw's pierce.
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * SuperradiantSlaughterer.ShootSpeed, ModContent.ProjectileType<SuperradiantSaw>(), (int)(Projectile.damage * sawDamageMult), Projectile.knockBack, Projectile.owner, sawLevel, 0f, sawPierce);
if (Main.myPlayer == Projectile.owner)
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * SuperradiantSlaughterer.ShootSpeed, ModContent.ProjectileType<SuperradiantSaw>(), (int)(Projectile.damage * sawDamageMult), Projectile.knockBack, Projectile.owner, sawLevel, 0f, sawPierce);
NoSawOnHoldout = true;
OffsetLengthFromArm -= 4f + 12f * SawPower;
+19 -22
View File
@@ -140,15 +140,9 @@ namespace CalamityMod.Projectiles.Ranged
SoundStyle fire = new("CalamityMod/Sounds/Custom/PlagueSounds/PBGBarrageLaunch");
SoundEngine.PlaySound(fire with { Volume = 0.5f, Pitch = 0.1f }, Projectile.Center);
Projectile.NewProjectileDirect(
Projectile.GetSource_FromThis(),
GunTipPosition,
shootDirection * projSpeed * 0.3f,
ProjectileType<HiveNuke>(),
damage * 10,
knockback,
Projectile.owner,
rocketType);
if (Main.myPlayer == Projectile.owner)
Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, shootDirection * projSpeed * 0.3f, ProjectileType<HiveNuke>(), damage * 10, knockback, Projectile.owner, rocketType);
PostFireCooldown = 75;
}
else
@@ -156,20 +150,23 @@ namespace CalamityMod.Projectiles.Ranged
SoundStyle fire = new("CalamityMod/Sounds/Custom/PlagueSounds/PBGBarrageLaunch");
SoundEngine.PlaySound(fire with { Volume = 0.4f, Pitch = 0.7f }, Projectile.Center);
int numProj = 4;
float rotation = MathHelper.ToRadians(MathHelper.Clamp(35 - VelocityMultiplier * 26, 2, 25));
for (int i = 0; i < numProj; i++)
if (Main.myPlayer == Projectile.owner)
{
Vector2 perturbedSpeed = (shootDirection).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1)));
Projectile.NewProjectileDirect(
Projectile.GetSource_FromThis(),
GunTipPosition,
perturbedSpeed * projSpeed * VelocityMultiplier,
ProjectileType<HiveMissile>(),
damage,
knockback,
Projectile.owner,
rocketType);
int numProj = 4;
float rotation = MathHelper.ToRadians(MathHelper.Clamp(35 - VelocityMultiplier * 26, 2, 25));
for (int i = 0; i < numProj; i++)
{
Vector2 perturbedSpeed = (shootDirection).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1)));
Projectile.NewProjectileDirect(
Projectile.GetSource_FromThis(),
GunTipPosition,
perturbedSpeed * projSpeed * VelocityMultiplier,
ProjectileType<HiveMissile>(),
damage,
knockback,
Projectile.owner,
rocketType);
}
}
PostFireCooldown = 30;
}
+3 -2
View File
@@ -41,10 +41,11 @@ namespace CalamityMod.Projectiles.Ranged
{
SoundEngine.PlaySound(SoundID.Item34, Projectile.Center);
Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextBool(2));
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (Projectile.velocity * 9).RotatedByRandom(0.08f), ModContent.ProjectileType<WildfireBloomFire>(), damage, knockback, Projectile.owner);
if (Main.myPlayer == Projectile.owner)
Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, (Projectile.velocity * 9).RotatedByRandom(0.08f), ModContent.ProjectileType<WildfireBloomFire>(), damage, knockback, Projectile.owner);
ShotsFired++;
ShotCooldown = HeldItem.useTime;
if (FireBlobs == 0)
if (FireBlobs == 0 && Main.myPlayer == Projectile.owner)
{
float randAngle = Main.rand.NextFloat(8f, 15f);
Vector2 newVel = (Projectile.velocity * 9).RotatedBy(MathHelper.ToRadians(randAngle)) * 2f;