diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 36cd4b5d72..6ee1ce42d9 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -586,6 +586,37 @@ namespace CalamityMod.Items } return false; } + if (player.HeldItem.type == ModContent.ItemType()) + { + bool hasBlades = false; + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f) + { + hasBlades = true; + break; + } + } + if (hasBlades) + { + for (int i = 0; i < Main.projectile.Length; i++) + { + if ((Main.projectile[i].modProjectile as IgneousBlade).Firing) + continue; + if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f) + { + Main.projectile[i].rotation = MathHelper.PiOver2 + MathHelper.PiOver4; + Main.projectile[i].velocity = Main.projectile[i].DirectionTo(Main.MouseWorld) * 16f; + Main.projectile[i].rotation += Main.projectile[i].velocity.ToRotation(); + Main.projectile[i].ai[0] = 180f; + (Main.projectile[i].modProjectile as IgneousBlade).Firing = true; + Main.projectile[i].tileCollide = true; + Main.projectile[i].netUpdate = true; + } + } + } + return false; + } return base.AltFunctionUse(item, player); } diff --git a/Items/Weapons/Summon/IgneousExaltation.cs b/Items/Weapons/Summon/IgneousExaltation.cs index 42737eaeb3..77cdc17c8c 100644 --- a/Items/Weapons/Summon/IgneousExaltation.cs +++ b/Items/Weapons/Summon/IgneousExaltation.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Igneous Exaltation"); Tooltip.SetDefault("Summons an orbiting blade\n" + - "If this item is used when you have no free minion slots, all knives are launched towards the cursor"); + "Right click to launch all blades towards the cursor"); Item.staff[item.type] = true; } @@ -37,15 +37,25 @@ namespace CalamityMod.Items.Weapons.Summon } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - if (player.altFunctionUse != 2) + float totalMinionSlots = 0f; + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && Main.projectile[i].minion && Main.projectile[i].owner == player.whoAmI) + { + totalMinionSlots += Main.projectile[i].minionSlots; + } + } + if (player.altFunctionUse != 2 && totalMinionSlots < player.maxMinions) { position = Main.MouseWorld; Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); int swordCount = 0; for (int i = 0; i < Main.projectile.Length; i++) { - if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f) + if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI) { + if ((Main.projectile[i].modProjectile as IgneousBlade).Firing) + continue; swordCount++; for (int j = 0; j < 22; j++) { @@ -61,6 +71,8 @@ namespace CalamityMod.Items.Weapons.Summon { if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f) { + if ((Main.projectile[i].modProjectile as IgneousBlade).Firing) + continue; Main.projectile[i].ai[0] = angle; angle += angleVariance; for (int j = 0; j < 22; j++) @@ -71,42 +83,6 @@ namespace CalamityMod.Items.Weapons.Summon } } } - float totalMinionSlots = 0f; - for (int i = 0; i < Main.projectile.Length; i++) - { - if (Main.projectile[i].active && Main.projectile[i].minion && Main.projectile[i].owner == player.whoAmI) - { - totalMinionSlots += Main.projectile[i].minionSlots; - } - } - if (totalMinionSlots >= player.maxMinions) - { - bool hasBlades = false; - for (int i = 0; i < Main.projectile.Length; i++) - { - if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f) - { - hasBlades = true; - break; - } - } - if (hasBlades) - { - for (int i = 0; i < Main.projectile.Length; i++) - { - if (Main.projectile[i].active && Main.projectile[i].type == ModContent.ProjectileType() && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].localAI[1] == 0f) - { - Main.projectile[i].rotation = MathHelper.PiOver2 + MathHelper.PiOver4; - Main.projectile[i].velocity = Main.projectile[i].DirectionTo(Main.MouseWorld) * 16f; - Main.projectile[i].rotation += Main.projectile[i].velocity.ToRotation(); - Main.projectile[i].ai[0] = 180f; - Main.projectile[i].localAI[1] = 1f; - Main.projectile[i].tileCollide = true; - Main.projectile[i].netUpdate = true; - } - } - } - } } return false; } diff --git a/Projectiles/Summon/DazzlingStabber.cs b/Projectiles/Summon/DazzlingStabber.cs index 242204111c..66ca9f1c03 100644 --- a/Projectiles/Summon/DazzlingStabber.cs +++ b/Projectiles/Summon/DazzlingStabber.cs @@ -132,9 +132,9 @@ namespace CalamityMod.Projectiles.Summon positionDelta = Utils.RandomVector2(Main.rand, -12f, 12f); projectile.Center = potentialTarget.Center + positionDelta; - projectile.rotation = projectile.AngleTo(potentialTarget.Center) + MathHelper.PiOver2; - projectile.rotation += angleMax; + projectile.rotation = projectile.AngleTo(potentialTarget.Center) + MathHelper.PiOver2 + angleMax; projectile.velocity = Vector2.Zero; + projectile.netUpdate = true; } if (projectile.ai[0] % 160f > 120f) { diff --git a/Projectiles/Summon/EndoHydraBody.cs b/Projectiles/Summon/EndoHydraBody.cs index ba170ca56b..c9ba3974aa 100644 --- a/Projectiles/Summon/EndoHydraBody.cs +++ b/Projectiles/Summon/EndoHydraBody.cs @@ -75,6 +75,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.ai[0] = potentialTarget.whoAmI; Main.PlaySound(SoundID.Zombie, projectile.Center, 53); // Ethereal whisper indicating a new target has been spotted. + projectile.netUpdate = true; } } diff --git a/Projectiles/Summon/IgneousBlade.cs b/Projectiles/Summon/IgneousBlade.cs index 74cd54deb3..56c6d78bc1 100644 --- a/Projectiles/Summon/IgneousBlade.cs +++ b/Projectiles/Summon/IgneousBlade.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using System.IO; using Terraria; @@ -11,10 +12,12 @@ namespace CalamityMod.Projectiles.Summon { public class IgneousBlade : ModProjectile { + public bool Firing = false; public override void SetStaticDefaults() { DisplayName.SetDefault("Igneous Blade"); - ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 7; } public override void SetDefaults() @@ -35,11 +38,11 @@ namespace CalamityMod.Projectiles.Summon } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(projectile.localAI[1]); + writer.Write(Firing); } public override void ReceiveExtraAI(BinaryReader reader) { - projectile.localAI[1] = reader.ReadSingle(); + Firing = reader.ReadBoolean(); } public override void AI() { @@ -73,7 +76,7 @@ namespace CalamityMod.Projectiles.Summon } // Orbiting. 1 = Shooting - if (projectile.localAI[1] == 0f) + if (!Firing) { const float outwardPosition = 180f; projectile.Center = player.Center + projectile.ai[0].ToRotationVector2() * outwardPosition; @@ -85,27 +88,41 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[0]--; if (projectile.ai[0] == 1) projectile.Kill(); + + if (projectile.ai[0] % 10f == 9f) + { + for (int i = 0; i < 20; i++) + { + float angle = MathHelper.TwoPi / 20f * i; + Dust dust = Dust.NewDustPerfect(projectile.position + angle.ToRotationVector2().RotatedBy(projectile.rotation) * new Vector2(14f, 21f), DustID.Fire); + dust.velocity = angle.ToRotationVector2().RotatedBy(projectile.rotation) * 2f; + dust.noGravity = true; + } + } } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (projectile.localAI[1] == 1f) + if (Firing) { - projectile.ai[0] = 50; - for (int i = 0; i < 3; i++) + if (Main.myPlayer == projectile.owner) { - Vector2 spawnPosition = target.Center - new Vector2(0f, 550f).RotatedByRandom(MathHelper.ToRadians(8f)); - Projectile.NewProjectile(spawnPosition, Vector2.Normalize(target.Center - spawnPosition) * 24f, ModContent.ProjectileType(), - (int)(projectile.damage * 0.666), projectile.knockBack, projectile.owner); + projectile.ai[0] = 50; + for (int i = 0; i < 3; i++) + { + Vector2 spawnPosition = target.Center - new Vector2(0f, 550f).RotatedByRandom(MathHelper.ToRadians(8f)); + Projectile.NewProjectile(spawnPosition, Vector2.Normalize(target.Center - spawnPosition) * 24f, ModContent.ProjectileType(), + (int)(projectile.damage * 0.666), projectile.knockBack, projectile.owner); + } + for (int i = 0; i < Main.rand.Next(28, 41); i++) + { + Dust.NewDustPerfect( + projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(10f), + 6, + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(1f, 4f)); + } + projectile.netUpdate = true; } - for (int i = 0; i < Main.rand.Next(28, 41); i++) - { - Dust.NewDustPerfect( - projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(10f), - 6, - Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(1f, 4f)); - } - projectile.netUpdate = true; } } public override void Kill(int timeLeft) @@ -117,5 +134,34 @@ namespace CalamityMod.Projectiles.Summon dust.noGravity = true; } } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (Firing) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/IgneousBlade"); + + Rectangle rectangle = new Rectangle(0, 0, texture.Width, texture.Height); + + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + if (Lighting.NotRetro) + { + for (int i = 0; i < projectile.oldPos.Length; i++) + { + Vector2 drawPos = projectile.oldPos[i] + projectile.Size / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Color color = Color.Lerp(Color.White, Color.Red, i / (float)projectile.oldPos.Length) * + ((projectile.oldPos.Length - i) / (float)projectile.oldPos.Length); + float scale = MathHelper.Lerp(projectile.scale * 1.35f, projectile.scale * 0.6f, i / (float)projectile.oldPos.Length); + Main.spriteBatch.Draw(texture, drawPos, new Rectangle?(rectangle), color, + projectile.rotation, + rectangle.Size() / 2f, scale, spriteEffects, 0f); + } + } + return false; + } + return true; + } } } diff --git a/Projectiles/Summon/MK2FlaskSummon.cs b/Projectiles/Summon/MK2FlaskSummon.cs index 77583f5e91..565e4b030d 100644 --- a/Projectiles/Summon/MK2FlaskSummon.cs +++ b/Projectiles/Summon/MK2FlaskSummon.cs @@ -32,15 +32,18 @@ namespace CalamityMod.Projectiles.Summon } public override void Kill(int timeLeft) { - for (int i = 0; i < Main.rand.Next(18, 21); i++) + if (Main.myPlayer == projectile.whoAmI) { - Dust.NewDustPerfect(projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(10f), - (int)CalamityDusts.Plague, - Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(1f, 4f)); + for (int i = 0; i < Main.rand.Next(18, 21); i++) + { + Dust.NewDustPerfect(projectile.Center + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(10f), + (int)CalamityDusts.Plague, + Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(1f, 4f)); + } + Main.PlaySound(SoundID.Item107, projectile.Center); + int idx = Projectile.NewProjectile(projectile.Center, Vector2.UnitY * 6f, ModContent.ProjectileType(), projectile.damage, 4f, projectile.owner); + Main.projectile[idx].ai[1] = CalamityUtils.CountProjectiles(ModContent.ProjectileType()); } - Main.PlaySound(SoundID.Item107, projectile.Center); - int idx = Projectile.NewProjectile(projectile.Center, Vector2.UnitY * 6f, ModContent.ProjectileType(), projectile.damage, 4f, projectile.owner); - Main.projectile[idx].ai[1] = CalamityUtils.CountProjectiles(ModContent.ProjectileType()); } public override bool CanDamage() => false; } diff --git a/Projectiles/Summon/PlaguebringerMK2.cs b/Projectiles/Summon/PlaguebringerMK2.cs index e77ac9ae50..7c06a48632 100644 --- a/Projectiles/Summon/PlaguebringerMK2.cs +++ b/Projectiles/Summon/PlaguebringerMK2.cs @@ -79,7 +79,7 @@ namespace CalamityMod.Projectiles.Summon projectile.velocity = velocity; } int timeNeeded = (int)MathHelper.Lerp(60f, 18f, MathHelper.Clamp(projectile.localAI[1] / 320f, 0f, 1f)); - if (projectile.ai[0] >= timeNeeded) + if (projectile.ai[0] >= timeNeeded && Main.myPlayer == projectile.owner) { Projectile.NewProjectile(projectile.Center, projectile.DirectionTo(potentialTarget.Center) * 14f, @@ -117,7 +117,10 @@ namespace CalamityMod.Projectiles.Summon Vector2 velocity = distanceToDestination.SafeNormalize(projectile.direction * Vector2.UnitX) * speed; projectile.velocity = (projectile.velocity * 20f + velocity) / 21f; if (distance > 2250f) + { projectile.Center = player.Center; + projectile.netUpdate = true; + } } else { @@ -137,8 +140,6 @@ namespace CalamityMod.Projectiles.Summon { projectile.frame = 0; } - - Lighting.AddLight(projectile.Center - Vector2.UnitY * 21f, 0.25f, 0.865f, 0.825f); } } } diff --git a/Projectiles/Summon/PowerfulRaven.cs b/Projectiles/Summon/PowerfulRaven.cs index 9e6f5bed57..24533b4ae2 100644 --- a/Projectiles/Summon/PowerfulRaven.cs +++ b/Projectiles/Summon/PowerfulRaven.cs @@ -79,6 +79,7 @@ namespace CalamityMod.Projectiles.Summon if (projectile.Distance(potentialTarget.Center) > TeleportDistance) { projectile.Center = potentialTarget.Center + Utils.NextVector2Unit(Main.rand) * potentialTarget.Size * 1.3f; + projectile.netUpdate = true; } else { @@ -87,9 +88,10 @@ namespace CalamityMod.Projectiles.Summon if (Main.rand.NextBool(6)) { projectile.Center = potentialTarget.Center + Utils.NextVector2Unit(Main.rand) * potentialTarget.Size * 1.3f; + projectile.netUpdate = true; for (int i = 0; i < 40; i++) { - float angle = MathHelper.TwoPi / 20f * i; + float angle = MathHelper.TwoPi / 40f * i; float lerp = MathHelper.Lerp(0f, 1f, (float)Math.Sin(i / 8f * MathHelper.TwoPi) * 0.5f + 0.5f); Dust dust = Dust.NewDustPerfect(projectile.position, DustID.Fire); dust.velocity = Vector2.Lerp(Vector2.Zero, angle.ToRotationVector2() * 6f, lerp); @@ -148,6 +150,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.Center = player.Center; projectile.velocity = Utils.NextVector2Unit(Main.rand) * 12f; + projectile.netUpdate = true; } else if (projectile.Distance(player.Center) > 90f) { diff --git a/Projectiles/Summon/RadiantResolutionAura.cs b/Projectiles/Summon/RadiantResolutionAura.cs index 8112d59c9f..f47aba8a72 100644 --- a/Projectiles/Summon/RadiantResolutionAura.cs +++ b/Projectiles/Summon/RadiantResolutionAura.cs @@ -83,7 +83,7 @@ namespace CalamityMod.Projectiles.Summon projectile.ai[1]++; NPC potentialTarget = projectile.Center.MinionHoming(DistanceToCheck, player); - if (potentialTarget != null) + if (potentialTarget != null && Main.myPlayer == projectile.whoAmI) { if (projectile.ai[1] % 35 == 34) { diff --git a/Projectiles/Summon/SkeletalDragonMother.cs b/Projectiles/Summon/SkeletalDragonMother.cs index 9c81b9aac4..40907b0e0a 100644 --- a/Projectiles/Summon/SkeletalDragonMother.cs +++ b/Projectiles/Summon/SkeletalDragonMother.cs @@ -124,8 +124,10 @@ namespace CalamityMod.Projectiles.Summon Main.projectile[i].type == ModContent.ProjectileType()) { Main.projectile[i].Center = player.Center; + Main.projectile[i].netUpdate = true; } } + projectile.netUpdate = true; } } projectile.direction = projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt();