From d21e76997964009e6ff2aaf0cc0e2723e6bfd275 Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:27:18 +0700 Subject: [PATCH] Overloaded Blaster revised --- .../TinyGreyscaleCircle.png | Bin Items/Weapons/Ranged/OverloadedBlaster.cs | 24 ++-- ...ods.CalamityMod.Items.Weapons.Ranged.hjson | 2 +- Projectiles/Melee/Orbacle.cs | 1 + Projectiles/Ranged/SlimeBolt.cs | 128 ++++++++++++------ 5 files changed, 94 insertions(+), 61 deletions(-) rename Projectiles/Melee/Orbacle.png => ExtraTextures/TinyGreyscaleCircle.png (100%) diff --git a/Projectiles/Melee/Orbacle.png b/ExtraTextures/TinyGreyscaleCircle.png similarity index 100% rename from Projectiles/Melee/Orbacle.png rename to ExtraTextures/TinyGreyscaleCircle.png diff --git a/Items/Weapons/Ranged/OverloadedBlaster.cs b/Items/Weapons/Ranged/OverloadedBlaster.cs index 411bed4f31..873af079aa 100644 --- a/Items/Weapons/Ranged/OverloadedBlaster.cs +++ b/Items/Weapons/Ranged/OverloadedBlaster.cs @@ -16,8 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.DamageType = DamageClass.Ranged; Item.width = 42; Item.height = 34; - Item.useTime = 18; - Item.useAnimation = 18; + Item.useAnimation = Item.useTime = 22; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; @@ -25,29 +24,22 @@ namespace CalamityMod.Items.Weapons.Ranged Item.rare = ItemRarityID.LightRed; Item.UseSound = SoundID.Item9; Item.autoReuse = true; - Item.shootSpeed = 4.5f; + Item.shootSpeed = 5f; Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Gel; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-4, -5); - } + public override Vector2? HoldoutOffset() => new Vector2(-4, -5); - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 33) - return false; - return true; - } + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 25; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - for (int index = 0; index < 3; ++index) + Vector2 newPos = position + velocity * 6f; + for (int i = 0; i < 3; i++) { - Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(0.6f, 1.1f); - Projectile.NewProjectile(source, position, newVel, type, damage, knockback, player.whoAmI); + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.8f, 1.2f); + Projectile.NewProjectile(source, newPos, newVel, type, damage, knockback, player.whoAmI); } return false; } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index c772ecd86c..4ddd5d7e4d 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -830,7 +830,7 @@ OverloadedBlaster: { Overloaded slime doesn't pierce, but deals double damage The slime bounces off of walls at high-velocity Uses gel for ammo - 33% chance to save ammo + 25% chance to save ammo ''' } diff --git a/Projectiles/Melee/Orbacle.cs b/Projectiles/Melee/Orbacle.cs index 45e1a73cce..afb422575d 100644 --- a/Projectiles/Melee/Orbacle.cs +++ b/Projectiles/Melee/Orbacle.cs @@ -7,6 +7,7 @@ namespace CalamityMod.Projectiles.Melee public class Orbacle : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/ExtraTextures/TinyGreyscaleCircle"; private static int Lifetime = 40; public override void SetDefaults() diff --git a/Projectiles/Ranged/SlimeBolt.cs b/Projectiles/Ranged/SlimeBolt.cs index 7a635d5357..bb1125def5 100644 --- a/Projectiles/Ranged/SlimeBolt.cs +++ b/Projectiles/Ranged/SlimeBolt.cs @@ -1,6 +1,7 @@ using CalamityMod.Particles; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,43 +11,46 @@ namespace CalamityMod.Projectiles.Ranged public class SlimeBolt : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/ExtraTextures/TinyGreyscaleCircle"; + + public static int Lifetime => 270; + public static float Fadetime => 225f; + public static float EmpowerTime => 135f; + public static Color SlimeColor => new Color (133, 133, 224); + + public ref float Time => ref Projectile.ai[0]; + public bool Empowered => Projectile.ai[0] >= EmpowerTime; + public ref float BloomPower => ref Projectile.ai[1]; + public bool Bounced => Projectile.ai[2] >= 1f; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } - public bool Empowered = false; - public int countdown = 90; - public bool postBounce = false; public override void SetDefaults() { - Projectile.width = 18; - Projectile.height = 18; + Projectile.width = Projectile.height = 20; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; - Projectile.timeLeft = 300; - Projectile.extraUpdates = 2; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 15 * Projectile.MaxUpdates; } public override void AI() { - if (countdown < 81) - { - Particle orb = new GenericBloom(Projectile.Center, Vector2.Zero, Color.SkyBlue, Empowered ? 0.22f : 0.17f, postBounce ? 2 : 5, true); - GeneralParticleHandler.SpawnParticle(orb); - } - if (countdown > -55 && Main.rand.NextBool(postBounce ? 2 : 7)) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10), Main.rand.NextBool(3) ? 16 : 20); - dust.scale = Main.rand.NextFloat(0.3f, 0.7f); - dust.velocity = -Projectile.velocity * 0.7f; - } - countdown--; - if (countdown <= 0) - Projectile.velocity *= 0.97f; - Vector3 DustLight = new Vector3(0.100f, 0.150f, 0.200f); - Lighting.AddLight(Projectile.Center, DustLight * 3); - if (countdown == -55) + Time++; + if (Time == EmpowerTime) { + Projectile.penetrate = 1; Projectile.damage *= 2; + Projectile.velocity *= 0f; + Projectile.rotation = Main.rand.NextFloat(0f, MathHelper.TwoPi); + float numberOfDusts = 10; float rotFactor = 360f / numberOfDusts; for (int i = 0; i < numberOfDusts; i++) @@ -60,42 +64,44 @@ namespace CalamityMod.Projectiles.Ranged dust.scale = Main.rand.NextFloat(1.2f, 1.9f); } } - if (countdown < -55 && Projectile.timeLeft % 10 == 0) - { - Empowered = true; - SparkParticle spark1 = new SparkParticle(Projectile.Center, new Vector2(0, 2), false, 7, 0.9f, Color.SkyBlue); - GeneralParticleHandler.SpawnParticle(spark1); - SparkParticle spark2 = new SparkParticle(Projectile.Center, new Vector2(0, -2), false, 7, 0.9f, Color.SkyBlue); - GeneralParticleHandler.SpawnParticle(spark2); - SparkParticle spark3 = new SparkParticle(Projectile.Center, new Vector2(2, 0), false, 7, 0.9f, Color.SkyBlue); - GeneralParticleHandler.SpawnParticle(spark3); - SparkParticle spark4 = new SparkParticle(Projectile.Center, new Vector2(-2, 0), false, 7, 0.9f, Color.SkyBlue); - GeneralParticleHandler.SpawnParticle(spark4); + else if (Time >= 90f) + Projectile.velocity *= 0.97f; - } if (Empowered) { - Projectile.penetrate = 1; + Projectile.rotation += MathHelper.ToRadians(2f); + if (Time >= Fadetime) + BloomPower = Utils.Remap(Time, Fadetime, Lifetime, 1.5f, 0f); + else + BloomPower = Utils.Remap(Time, EmpowerTime, Fadetime, 0f, 1.5f); } + else if (Main.rand.NextBool(Bounced ? 2 : 7)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10), Main.rand.NextBool(3) ? 16 : 20); + dust.scale = Main.rand.NextFloat(0.3f, 0.7f); + dust.velocity = -Projectile.velocity * 0.7f; + } + + Lighting.AddLight(Projectile.Center, 0.3f, 0.3f, 0.5f); } public override bool OnTileCollide(Vector2 oldVelocity) { if (Projectile.velocity.X != oldVelocity.X) { - Projectile.velocity.X = -oldVelocity.X * (postBounce ? 1f : 3f); + Projectile.velocity.X = -oldVelocity.X * (Bounced ? 1f : Utils.Remap(Time, 0f, EmpowerTime, 1.5f, 4f)); } if (Projectile.velocity.Y != oldVelocity.Y) { - Projectile.velocity.Y = -oldVelocity.Y * (postBounce ? 1f : 3f); + Projectile.velocity.Y = -oldVelocity.Y * (Bounced ? 1f : Utils.Remap(Time, 0f, EmpowerTime, 1.5f, 4f)); } - postBounce = true; + Projectile.ai[2]++; return false; } public override void OnKill(int timeLeft) { - Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.SkyBlue, new Vector2(1f, 1f), Main.rand.NextFloat(5, -5), 0f, 0.4f, 25); + Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, SlimeColor, Vector2.One, 0f, 0f, 0.4f, 25); GeneralParticleHandler.SpawnParticle(pulse); } @@ -104,7 +110,7 @@ namespace CalamityMod.Projectiles.Ranged target.AddBuff(BuffID.Slimed, Empowered ? 480 : 180); if (Empowered) { - Particle pulse2 = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, Color.SkyBlue, new Vector2(1f, 1f), Main.rand.NextFloat(5, -5), 0f, 0.65f, 35); + Particle pulse2 = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, SlimeColor, Vector2.One, 0f, 0f, 0.65f, 35); GeneralParticleHandler.SpawnParticle(pulse2); float numberOfDusts = 12; float rotFactor = 360f / numberOfDusts; @@ -113,7 +119,7 @@ namespace CalamityMod.Projectiles.Ranged float rot = MathHelper.ToRadians(i * rotFactor); Vector2 offset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot); Vector2 velOffset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot); - Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 34 : 59, new Vector2(velOffset.X, velOffset.Y)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 34 : 59, velOffset); dust.noGravity = false; dust.alpha = 130; dust.velocity = velOffset; @@ -121,5 +127,39 @@ namespace CalamityMod.Projectiles.Ranged } } } + + public override bool PreDraw(ref Color lightColor) + { + Main.spriteBatch.SetBlendState(BlendState.Additive); + + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Main.EntitySpriteDraw(texture, drawPosition, null, SlimeColor, Projectile.rotation, texture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + + if (Empowered) + { + Texture2D shineTex = ModContent.Request("CalamityMod/Particles/Sparkle").Value; + Texture2D bloomTex = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Main.EntitySpriteDraw(bloomTex, drawPosition, null, SlimeColor * 0.5f, Projectile.rotation, bloomTex.Size() * 0.5f, BloomPower * Projectile.scale * 0.3f, SpriteEffects.None); + Main.EntitySpriteDraw(shineTex, drawPosition, null, SlimeColor, Projectile.rotation, shineTex.Size() * 0.5f, BloomPower * Projectile.scale, SpriteEffects.None); + } + else + { + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + float completionRatio = i / (float)Projectile.oldPos.Length; + Vector2 trailPos = Projectile.oldPos[i] + texture.Size() * 0.5f - Main.screenPosition; + + // The further the smaller + Color trailColor = Color.Lerp(SlimeColor, Color.Black, completionRatio); + float trailScale = MathHelper.Lerp(0.15f, 1f, 1f - completionRatio); + + Main.EntitySpriteDraw(texture, trailPos, null, trailColor, 0f, texture.Size() * 0.5f, Projectile.scale * trailScale, SpriteEffects.None, 0); + } + } + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; + } } }