diff --git a/Items/Weapons/Magic/PhantasmalFury.cs b/Items/Weapons/Magic/PhantasmalFury.cs index f50734ad0f..fe93d842ff 100644 --- a/Items/Weapons/Magic/PhantasmalFury.cs +++ b/Items/Weapons/Magic/PhantasmalFury.cs @@ -3,6 +3,8 @@ using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -20,23 +22,40 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 62; Item.height = 60; - Item.damage = 260; + Item.damage = 115; Item.DamageType = DamageClass.Magic; - Item.mana = 20; - Item.useTime = 20; - Item.useAnimation = 20; + Item.mana = 60; + Item.useTime = 3; + Item.useAnimation = 45; + Item.reuseDelay = 75; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 7.5f; + Item.knockBack = 20f; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; - Item.UseSound = SoundID.Item43; + Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/PhantasmalFuryShoot") with { Volume = 0.6f, PitchVariance = 0.15f }; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 12f; + Item.shootSpeed = 6f; Item.rare = ModContent.RarityType(); } - + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Projectile.NewProjectileDirect(source, position + velocity * 13, velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.8f, 1.1f), ModContent.ProjectileType(), damage, 0, player.whoAmI, 0f, 0f); + for (int i = 0; i < 2; i++) + { + Projectile.NewProjectileDirect(source, position + velocity * 13, velocity.RotatedByRandom(0.4f), ModContent.ProjectileType(), damage / 2, 0, player.whoAmI, 0f, 0f); + } + for (int i = 0; i < 2; i++) + { + Dust chargefull = Dust.NewDustPerfect(position + velocity * 13, 267); + chargefull.velocity = velocity.RotatedByRandom(0.25f) * Main.rand.NextFloat(1f, 4); + chargefull.scale = Main.rand.NextFloat(0.5f, 0.9f); + chargefull.noGravity = true; + chargefull.color = Color.Lerp(Color.White, Color.Aqua, 0.3f); + } + return false; + } public override void AddRecipes() { CreateRecipe(). diff --git a/Projectiles/Magic/PhantasmalFuryProj.cs b/Projectiles/Magic/PhantasmalFuryProj.cs index 806fdadff5..b143d621a9 100644 --- a/Projectiles/Magic/PhantasmalFuryProj.cs +++ b/Projectiles/Magic/PhantasmalFuryProj.cs @@ -1,5 +1,7 @@ using System; +using System.Threading.Channels; using Microsoft.Xna.Framework; +using Steamworks; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -9,11 +11,14 @@ namespace CalamityMod.Projectiles.Magic public class PhantasmalFuryProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; + public int time = 0; + public float dustRotation = 0; + public bool launched = false; public override void SetStaticDefaults() { Main.projFrames[Projectile.type] = 4; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; } public override void SetDefaults() @@ -22,13 +27,19 @@ namespace CalamityMod.Projectiles.Magic Projectile.height = 16; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.penetrate = 1; - Projectile.timeLeft = 120; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.extraUpdates = 5; + Projectile.timeLeft = 900; Projectile.DamageType = DamageClass.Magic; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 20 * Projectile.extraUpdates; + Projectile.ArmorPenetration = 15; } public override void AI() { + Player Owner = Main.player[Projectile.owner]; Projectile.frameCounter++; if (Projectile.frameCounter > 4) { @@ -38,51 +49,94 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.frame >= Main.projFrames[Projectile.type]) Projectile.frame = 0; - if (Projectile.timeLeft % 10 == 0) - { - if (Projectile.owner == Main.myPlayer) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - } - if (Projectile.timeLeft < 100) - { - CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 10f, 20f); - } + dustRotation += 0.12f; + Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 0.5f); - Lighting.AddLight(Projectile.Center, 0.25f, 0.25f, 0.25f); - - for (int i = 0; i < 3; i++) - { - int spectre = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.SpectreStaff, 0f, 0f, 100, default, 2f); - Main.dust[spectre].noGravity = true; - Main.dust[spectre].velocity *= 0.5f; - Main.dust[spectre].velocity += Projectile.velocity * 0.1f; - } + // 175, 100 ALPHA Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); + + if (time >= 500) + { + if (time == 500) + { + Projectile.penetrate = 1; + launched = true; + } + + NPC target = Projectile.Center.ClosestNPCAt(700); + if (target != null && target.CanBeChasedBy(Projectile)) + { + Vector2 moveTotarget = (target.Center - Projectile.Center).SafeNormalize(Vector2.UnitX); + if (Projectile.velocity.Length() < 6) + Projectile.velocity += moveTotarget * 0.45f; + else + Projectile.velocity *= 0.9f; + } + + if (time < 550 && target == null) + { + if (Projectile.velocity.Length() < 6) + Projectile.velocity += (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX) * 0.35f; + else + Projectile.velocity *= 0.9f; + } + } + else if (time > 15) + { + Vector2 circle = Owner.Center + new Vector2(0, -30).RotatedBy(time * 0.05f); + Vector2 moveToEnemy = (circle - Projectile.Center).SafeNormalize(Vector2.UnitX); + if (Projectile.velocity.Length() < 8) + Projectile.velocity += moveToEnemy * Main.rand.NextFloat(0.2f, 0.4f); + else + Projectile.velocity *= 0.85f; + } + + if (time > 5) + { + Vector2 dustPos = Projectile.Center + (MathHelper.Pi + dustRotation + MathHelper.PiOver2).ToRotationVector2() * 10f * Projectile.scale; + Dust dust = Dust.NewDustPerfect(dustPos, 175, (MathHelper.Pi + dustRotation * Math.Sign(Projectile.velocity.Length())).ToRotationVector2() * 2); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.75f, 1.2f); + dust.alpha = Main.rand.Next(100, 170 + 1); + dust.velocity = dust.velocity.RotatedByRandom(0f); + } + time++; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SourceDamage *= (launched ? 1f : 0.05f); + + Player Owner = Main.player[Projectile.owner]; + if (target.CanBeMoved(true)) + { + // Custom knockback + Vector2 launchVel = (Owner.Center - target.Center).SafeNormalize(Vector2.UnitY) * -10 * (launched ? 0.5f : 2); + target.velocity = launchVel * (target.knockBackResist == 0 ? 0.5f : 1f); + } } public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item43, Projectile.Center); - for (int j = 0; j <= 10; j++) + //SoundEngine.PlaySound(SoundID.Item43, Projectile.Center); + for (int i = 0; i <= 3; i++) { - Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.SpectreStaff, 0f, 0f, 100, default, 1f); - } - if (Projectile.owner == Main.myPlayer) - { - for (int i = 0; i < 8; i++) - { - Vector2 velocity = (MathHelper.TwoPi * i / 8f).ToRotationVector2() * 3f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); - } + Dust dust = Dust.NewDustPerfect(Projectile.Center, 175, (Projectile.velocity * 6).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(1.2f, 1.8f)); + dust.noGravity = true; + Dust chargefull = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 278 : 267); + chargefull.velocity = Projectile.velocity.RotatedByRandom(0.25f) * Main.rand.NextFloat(1f, 4); + chargefull.scale = Main.rand.NextFloat(0.5f, 0.9f); + chargefull.noGravity = true; + chargefull.color = Color.Lerp(Color.White, Color.Aqua, 0.3f); } } public override bool PreDraw(ref Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Color.White, 1); + return false; } } diff --git a/Projectiles/Magic/Phantom.cs b/Projectiles/Magic/Phantom.cs index 16f456274e..b8223463ac 100644 --- a/Projectiles/Magic/Phantom.cs +++ b/Projectiles/Magic/Phantom.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,31 +9,121 @@ namespace CalamityMod.Projectiles.Magic public class Phantom : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; + public float sizeVariance = 2; + public int time = 0; + public int spinDir = 100; + public int waveOften = 40; + public float scaleVariance = 1; + + public bool launched = false; public override void SetDefaults() { Projectile.width = 8; Projectile.height = 8; Projectile.friendly = true; - Projectile.extraUpdates = 1; - Projectile.penetrate = 2; + Projectile.extraUpdates = 5; + Projectile.penetrate = -1; Projectile.ignoreWater = true; - Projectile.timeLeft = 120; + Projectile.tileCollide = false; + Projectile.timeLeft = 900; Projectile.DamageType = DamageClass.Magic; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 20 * Projectile.extraUpdates; + Projectile.ArmorPenetration = 30; } public override void AI() { - Projectile.rotation += 0.01f; + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); - Lighting.AddLight(Projectile.Center, 0.2f, 0.2f, 0.2f); + Projectile.rotation += Main.rand.NextFloat(0.02f, 0.09f); - for (int i = 0; i < 2; i++) + if (spinDir == 100) { - int spectre = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.SpectreStaff, 0f, 0f, 100, default, 1f); - Main.dust[spectre].noGravity = true; + spinDir = Main.rand.NextBool() ? 1 : -1; + waveOften = Main.rand.Next(10, 40 + 1); + Projectile.scale = Main.rand.NextFloat(0.95f, 1.1f); } - CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 300f, 12f, 20f); + Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 0.3f); + + if (time % 2 == 0 && time > 3 && targetDist < 1400) + { + Particle spark = new GlowSparkParticle(Projectile.Center + Projectile.velocity * Main.rand.NextFloat(-1, 1), -Projectile.velocity * 0.3f, false, 4, 0.025f, Color.Lerp(Color.White, Color.Aqua, 0.3f) * 0.6f, new Vector2(1, 0.3f), true, false, 2); + GeneralParticleHandler.SpawnParticle(spark); + } + + if (time >= 500) + { + if (time == 500) + { + Projectile.penetrate = 1; + Projectile.velocity = (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX) * 6; + launched = true; + } + + float badDist = Vector2.Distance(Owner.Calamity().mouseWorld, Projectile.Center); + if (badDist < 30) + { + time = 600; + } + + NPC target = Projectile.Center.ClosestNPCAt(550); + + if (target != null) + { + Vector2 moveToEnemy = (target.Center - Projectile.Center).SafeNormalize(Vector2.UnitX); + if (Projectile.velocity.Length() < 6) + Projectile.velocity += moveToEnemy * 0.3f; + else + Projectile.velocity *= 0.85f; + } + + if (time < 550 && target == null) + { + if (Projectile.velocity.Length() < 6) + Projectile.velocity += (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX) * 0.35f; + else + Projectile.velocity *= 0.9f; + } + + if (time % waveOften == 0) + spinDir *= -1; + + Projectile.velocity = Projectile.velocity.RotatedBy(Main.rand.NextFloat(0.01f, 0.02f) * spinDir); + } + else if (time > 15) + { + Vector2 circle = Owner.Center + new Vector2(0, -30).RotatedBy(time * 0.05f); + Vector2 moveToEnemy = (circle - Projectile.Center).SafeNormalize(Vector2.UnitX); + if (Projectile.velocity.Length() < 8) + Projectile.velocity += moveToEnemy * Main.rand.NextFloat(0.2f, 0.4f); + else + Projectile.velocity *= 0.85f; + } + + time++; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SourceDamage *= (launched ? 1f : 0.05f); + + Player Owner = Main.player[Projectile.owner]; + if (target.CanBeMoved(true)) + { + // Custom knockback + Vector2 launchVel = (Owner.Center - target.Center).SafeNormalize(Vector2.UnitY) * -10 * (launched ? 0.5f : 2); + target.velocity = launchVel * (target.knockBackResist == 0 ? 0.5f : 1f); + } + } + public override void OnKill(int timeLeft) + { + for (int i = 0; i <= 2; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, 175, (Projectile.velocity * 3).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.3f)); + dust.noGravity = true; + } } } } diff --git a/Projectiles/Magic/Shadowbolt.cs b/Projectiles/Magic/Shadowbolt.cs index 15ec56342b..39192a3d4e 100644 --- a/Projectiles/Magic/Shadowbolt.cs +++ b/Projectiles/Magic/Shadowbolt.cs @@ -85,7 +85,7 @@ namespace CalamityMod.Projectiles.Magic } } - if (spawnPlat) + if (spawnPlat && hasSetPlatSpawn) { chosenTarget = Projectile.Center.ClosestNPCAt(2000); @@ -95,7 +95,7 @@ namespace CalamityMod.Projectiles.Magic targetCenter = chosenTarget.Center; platPosCenter = Projectile.Center + Projectile.velocity * Main.rand.Next(70, 120 + 1); - platRot = (targetCenter - platPosCenter).SafeNormalize(Vector2.UnitX).ToRotation(); + platRot = (Projectile.Center - platPosCenter).SafeNormalize(Vector2.UnitX).ToRotation(); platPosWall = platPosCenter + new Vector2(0, 8).RotatedBy(platRot); spawnPlat = false; } @@ -106,7 +106,7 @@ namespace CalamityMod.Projectiles.Magic else targetCenter = chosenTarget.Center; - platRot = platRot.AngleLerp((targetCenter - platPosCenter).SafeNormalize(Vector2.UnitX).ToRotation(), 0.2f); + platRot = platRot.AngleLerp((targetCenter - platPosCenter).SafeNormalize(Vector2.UnitX).ToRotation(), 0.1f); platPosWall = platPosCenter + new Vector2(0, -30).RotatedBy(platRot + MathHelper.ToRadians(90f)); } if (!spawnPlat && !hasReboundOffPlat && targetCenter != Vector2.Zero) diff --git a/Sounds/Item/PhantasmalFuryShoot.ogg b/Sounds/Item/PhantasmalFuryShoot.ogg new file mode 100644 index 0000000000..27b47390c1 Binary files /dev/null and b/Sounds/Item/PhantasmalFuryShoot.ogg differ