diff --git a/Items/Weapons/Ranged/Scorpio.cs b/Items/Weapons/Ranged/Scorpio.cs index fe1a074b26..211317a91c 100644 --- a/Items/Weapons/Ranged/Scorpio.cs +++ b/Items/Weapons/Ranged/Scorpio.cs @@ -1,10 +1,12 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Items.Weapons.Ranged { @@ -34,12 +36,13 @@ namespace CalamityMod.Items.Weapons.Ranged public static readonly SoundStyle RocketShoot = new("CalamityMod/Sounds/Item/ScorpioShot") { Volume = 0.45f }; public static readonly SoundStyle RocketHit = new("CalamityMod/Sounds/Item/ScorpioHit") { Volume = 0.35f }; public static readonly SoundStyle NukeHit = new("CalamityMod/Sounds/Item/ScorpioNukeHit") { Volume = 0.6f }; + public override void SetDefaults() { Item.damage = 20; Item.DamageType = DamageClass.Ranged; Item.useTime = Item.useAnimation = OriginalUseTime; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ProjectileType(); Item.shootSpeed = 15f; Item.knockBack = 6.5f; @@ -65,7 +68,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI, -30); + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ProjectileType(), 0, 0f, player.whoAmI, -30); // We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out. holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); @@ -73,6 +76,8 @@ namespace CalamityMod.Items.Weapons.Ranged return false; } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) => Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, Request("CalamityMod/Items/Weapons/Ranged/Scorpio_Glow").Value); + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/Scorpio_Glow.png b/Items/Weapons/Ranged/Scorpio_Glow.png new file mode 100644 index 0000000000..ad4c620482 Binary files /dev/null and b/Items/Weapons/Ranged/Scorpio_Glow.png differ diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index e577d5e7df..5a8a8c3b9e 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -241,5 +241,5 @@ WaterSpout.DisplayName: Spout WulfrumScrapBullet.DisplayName: High Speed Scrap DragonsBreathFlames.DisplayName: Draconic Flames DragonsBreathMag.DisplayName: Dragons Breath Cartridge -ScorpioLargeRocket.DisplayName: Scorpio Nuke -ScorpioRocket.DisplayName: Scorpio Missile +ScorpioLargeRocket.DisplayName: Nano Nuke +ScorpioRocket.DisplayName: Nano Missile diff --git a/Projectiles/Ranged/ScorpioHoldout.cs b/Projectiles/Ranged/ScorpioHoldout.cs index 0f51fcb6d4..771eab1869 100644 --- a/Projectiles/Ranged/ScorpioHoldout.cs +++ b/Projectiles/Ranged/ScorpioHoldout.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Projectiles.Ranged public Player Owner { get; set; } public ref float ShootingTimer => ref Projectile.ai[0]; public ref float TimerBetweenBursts => ref Projectile.ai[1]; + public ref float ChargeLV => ref Projectile.ai[2]; public ref float OffsetLengthScalar => ref Projectile.localAI[0]; - public int ChargeLV = 0; // The maximum amount that the gun is away from the player's hands. public const float MaxOffsetScalarLength = 15f; @@ -291,6 +291,7 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(ref Color lightColor) { Texture2D texture = Request(Texture).Value; + Texture2D glowTexture = Request("CalamityMod/Projectiles/Ranged/ScorpioHoldout_Glow").Value; Vector2 drawPosition = Projectile.Center - Main.screenPosition; Color drawColor = Projectile.GetAlpha(lightColor); float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); @@ -298,6 +299,7 @@ namespace CalamityMod.Projectiles.Ranged SpriteEffects flipSprite = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, flipSprite); + Main.EntitySpriteDraw(glowTexture, drawPosition, null, Color.White, drawRotation, rotationPoint, Projectile.scale, flipSprite); return false; } diff --git a/Projectiles/Ranged/ScorpioHoldout_Glow.png b/Projectiles/Ranged/ScorpioHoldout_Glow.png new file mode 100644 index 0000000000..ad4c620482 Binary files /dev/null and b/Projectiles/Ranged/ScorpioHoldout_Glow.png differ diff --git a/Projectiles/Ranged/ScorpioLargeRocket.cs b/Projectiles/Ranged/ScorpioLargeRocket.cs index cae2fcf02e..14b693cb02 100644 --- a/Projectiles/Ranged/ScorpioLargeRocket.cs +++ b/Projectiles/Ranged/ScorpioLargeRocket.cs @@ -19,6 +19,8 @@ namespace CalamityMod.Projectiles.Ranged public ref float RocketID => ref Projectile.ai[0]; public ref float ProjectileSpeed => ref Projectile.ai[1]; + public static int Lifetime = 600; + public override void SetStaticDefaults() { Main.projFrames[Type] = 4; @@ -31,7 +33,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.MaxUpdates = 3; Projectile.width = Projectile.height = 15; - Projectile.timeLeft = 600; + Projectile.timeLeft = Lifetime; Projectile.localNPCHitCooldown = -1; Projectile.friendly = true; @@ -45,13 +47,23 @@ namespace CalamityMod.Projectiles.Ranged if (target is not null) { Vector2 targetDirection = Projectile.SafeDirectionTo(target.Center); + + // If the projectile is aligned a certain amount to the direction to the target, it gets small homing. float trackingSpeed = Vector2.Dot(targetDirection, Projectile.rotation.ToRotationVector2()) > NukeRequiredRotationProximity ? NukeTrackingSpeed : 0f; + Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(targetDirection.ToRotation(), trackingSpeed).ToRotationVector2() * ProjectileSpeed; } + Projectile.velocity *= 1.032f; + + if (Projectile.wet && RocketID == ItemID.DryRocket && RocketID == ItemID.WetRocket && RocketID == ItemID.LavaRocket && RocketID == ItemID.HoneyRocket) + Projectile.Kill(); + + // Every X frames it changes the projectile to its next animation frame. Projectile.frameCounter++; if (Projectile.frameCounter >= 4) { + // Cycles through the 4 frames of the animation. Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type]; Projectile.frameCounter = 0; } @@ -59,6 +71,8 @@ namespace CalamityMod.Projectiles.Ranged // Rotates towards its velocity. Projectile.rotation = Projectile.velocity.ToRotation(); + // Inside here go all the things that dedicated servers shouldn't spend resources on. + // Like visuals and sounds. if (Main.dedServ) return; @@ -70,29 +84,28 @@ namespace CalamityMod.Projectiles.Ranged trailDust.noLight = true; trailDust.noLightEmittence = true; - if (Projectile.timeLeft < 595) + if (Projectile.timeLeft < Lifetime - 5) { SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity * 2f, Projectile.velocity * 0.01f, false, 8, 1.3f, StaticEffectsColor); GeneralParticleHandler.SpawnParticle(spark); } - + if (Projectile.timeLeft % 3 == 0) { Particle nanoDust = new NanoParticle(Projectile.Center, -Projectile.velocity.RotatedBy(Main.rand.NextFloat(-0.2f, 0.2f)), Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor, Main.rand.NextFloat(0.65f, 0.9f), Main.rand.Next(15, 20 + 1), Main.rand.NextBool(), true); GeneralParticleHandler.SpawnParticle(nanoDust); } - Particle blastRing = new DirectionalPulseRing( - Projectile.Center + Projectile.velocity * 1.5f, - Vector2.Zero, - StaticEffectsColor * 2, - Vector2.One, - 0f, - 0.25f, - 0.25f, - 2); - GeneralParticleHandler.SpawnParticle(blastRing); - Projectile.velocity *= 1.032f; + Particle blastRing = new DirectionalPulseRing( + Projectile.Center + Projectile.velocity * 1.5f, + Vector2.Zero, + StaticEffectsColor * 2, + Vector2.One, + 0f, + 0.25f, + 0.25f, + 2); + GeneralParticleHandler.SpawnParticle(blastRing); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) @@ -109,9 +122,14 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { - var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID); + var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID) + { + smallRadius = 13, + mediumRadius = 26, + largeRadius = 40 + }; int blastRadius = Projectile.RocketBehavior(info); - Projectile.ExpandHitboxBy((float)blastRadius * 4.4f); + Projectile.ExpandHitboxBy(blastRadius); Projectile.Damage(); // Inside here go all the things that dedicated servers shouldn't spend resources on. @@ -119,8 +137,6 @@ namespace CalamityMod.Projectiles.Ranged if (Main.dedServ) return; - SoundEngine.PlaySound(RocketHit, Projectile.Center); - int dustAmount = Main.rand.Next(30, 35 + 1); for (int i = 0; i < dustAmount; i++) { @@ -129,6 +145,7 @@ namespace CalamityMod.Projectiles.Ranged boomDust.noLight = true; boomDust.noLightEmittence = true; } + for (int i = 0; i < 40; i++) { float blastVel = Projectile.width / 33f; @@ -159,8 +176,6 @@ namespace CalamityMod.Projectiles.Ranged 20); GeneralParticleHandler.SpawnParticle(blastRing); - SoundEngine.PlaySound(NukeHit, Projectile.Center); - Vector2 BurstFXDirection = new Vector2(15, 0); for (int i = 0; i < 4; i++) { @@ -177,13 +192,15 @@ namespace CalamityMod.Projectiles.Ranged GeneralParticleHandler.SpawnParticle(orb); Particle orb2 = new GenericBloom(Projectile.Center, Vector2.Zero, Color.White, 1.5f, 12, false); GeneralParticleHandler.SpawnParticle(orb2); + + SoundEngine.PlaySound(RocketHit, Projectile.Center); + SoundEngine.PlaySound(NukeHit, Projectile.Center); } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (Projectile.numHits < 1) - { Main.player[Projectile.owner].Calamity().GeneralScreenShakePower = 6f; - } } public float TrailWidthFunction(float completionRatio) => Utils.Remap(completionRatio, 0f, 0.8f, 15f, 0f); @@ -192,6 +209,7 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(ref Color lightColor) { Texture2D texture = Request(Texture).Value; + Texture2D glowTexture = Request("CalamityMod/Projectiles/Ranged/ScorpioLargeRocket_Glow").Value; Vector2 drawPosition = Projectile.Center - Main.screenPosition; Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); Color drawColor = Projectile.GetAlpha(lightColor); @@ -203,6 +221,7 @@ namespace CalamityMod.Projectiles.Ranged trail.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 25); Main.EntitySpriteDraw(texture, drawPosition, frame, drawColor, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); + Main.EntitySpriteDraw(glowTexture, drawPosition, frame, Color.White, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); return false; } diff --git a/Projectiles/Ranged/ScorpioLargeRocket_Glow.png b/Projectiles/Ranged/ScorpioLargeRocket_Glow.png new file mode 100644 index 0000000000..c2eb703948 Binary files /dev/null and b/Projectiles/Ranged/ScorpioLargeRocket_Glow.png differ diff --git a/Projectiles/Ranged/ScorpioRocket.cs b/Projectiles/Ranged/ScorpioRocket.cs index 450a73bb56..4162d3826b 100644 --- a/Projectiles/Ranged/ScorpioRocket.cs +++ b/Projectiles/Ranged/ScorpioRocket.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Particles; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -21,8 +20,8 @@ namespace CalamityMod.Projectiles.Ranged public ref float ProjectileSpeed => ref Projectile.ai[1]; public ref float Time => ref Projectile.ai[2]; - public const float TimeToLaunch = 15f; - public const float TimeForFullPropulsion = 10f; + public static float TimeToLaunch = 15f; + public static float TimeForFullPropulsion = 10f; public override void SetStaticDefaults() { @@ -37,9 +36,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.width = Projectile.height = 34; Projectile.timeLeft = 600; Projectile.localNPCHitCooldown = -1; - Projectile.friendly = true; - Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; } @@ -75,6 +72,9 @@ namespace CalamityMod.Projectiles.Ranged else Projectile.velocity *= 0.9f; + if (Projectile.wet && RocketID == ItemID.DryRocket && RocketID == ItemID.WetRocket && RocketID == ItemID.LavaRocket && RocketID == ItemID.HoneyRocket) + Projectile.Kill(); + // Rotates towards its velocity. Projectile.rotation = Projectile.velocity.ToRotation(); @@ -109,7 +109,13 @@ namespace CalamityMod.Projectiles.Ranged boomDust.noLightEmittence = true; } - SoundEngine.PlaySound(RocketHit, Projectile.Center); + for (int i = 0; i < 7; i++) + { + float blastVel = Projectile.width / 35f; + Vector2 velocity = new Vector2(blastVel, blastVel).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f); + Particle nanoDust = new NanoParticle(Projectile.Center, velocity, Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor, Main.rand.NextFloat(1f, 1.5f), 40, Main.rand.NextBool(), true); + GeneralParticleHandler.SpawnParticle(nanoDust); + } Particle smallBlastRing = new DirectionalPulseRing( Projectile.Center, @@ -132,13 +138,8 @@ namespace CalamityMod.Projectiles.Ranged Projectile.width / 175f, 20); GeneralParticleHandler.SpawnParticle(blastRing); - for (int i = 0; i < 7; i++) - { - float blastVel = Projectile.width / 35f; - Vector2 velocity = new Vector2(blastVel, blastVel).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f); - Particle nanoDust = new NanoParticle(Projectile.Center, velocity, Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor, Main.rand.NextFloat(1f, 1.5f), 40, Main.rand.NextBool(), true); - GeneralParticleHandler.SpawnParticle(nanoDust); - } + + SoundEngine.PlaySound(RocketHit, Projectile.Center); } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { @@ -156,6 +157,7 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreDraw(ref Color lightColor) { Texture2D texture = Request(Texture).Value; + Texture2D glowTexture = Request("CalamityMod/Projectiles/Ranged/ScorpioRocket_Glow").Value; Vector2 drawPosition = Projectile.Center - Main.screenPosition; Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); Color drawColor = Projectile.GetAlpha(lightColor); @@ -170,6 +172,7 @@ namespace CalamityMod.Projectiles.Ranged } Main.EntitySpriteDraw(texture, drawPosition, frame, drawColor, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); + Main.EntitySpriteDraw(glowTexture, drawPosition, frame, Color.White, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); return false; } diff --git a/Projectiles/Ranged/ScorpioRocket_Glow.png b/Projectiles/Ranged/ScorpioRocket_Glow.png new file mode 100644 index 0000000000..43795c3b9e Binary files /dev/null and b/Projectiles/Ranged/ScorpioRocket_Glow.png differ