From e46fdd435776f45d2ef34794e19fc8cb46cbc4f1 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Wed, 3 Mar 2021 21:24:40 -0500 Subject: [PATCH] Finished Telluric Glare rework. --- Items/Weapons/Ranged/TelluricGlare.cs | 48 +++---- Projectiles/Ranged/TelluricGlareArrow.cs | 135 ++++++++++++++++++ ...icGlareProj.png => TelluricGlareArrow.png} | Bin Projectiles/Ranged/TelluricGlareProj.cs | 98 ------------- 4 files changed, 159 insertions(+), 122 deletions(-) create mode 100644 Projectiles/Ranged/TelluricGlareArrow.cs rename Projectiles/Ranged/{TelluricGlareProj.png => TelluricGlareArrow.png} (100%) delete mode 100644 Projectiles/Ranged/TelluricGlareProj.cs diff --git a/Items/Weapons/Ranged/TelluricGlare.cs b/Items/Weapons/Ranged/TelluricGlare.cs index 507984278a..9aad9036c6 100644 --- a/Items/Weapons/Ranged/TelluricGlare.cs +++ b/Items/Weapons/Ranged/TelluricGlare.cs @@ -8,50 +8,50 @@ namespace CalamityMod.Items.Weapons.Ranged { public class TelluricGlare : ModItem { - public const int RayCount = 4; public override void SetStaticDefaults() { DisplayName.SetDefault("Telluric Glare"); - Tooltip.SetDefault($"Fires a burst of {RayCount} solar rays outward"); + Tooltip.SetDefault("Fires volleys of four colossal radiant arrows which can pass through walls"); } public override void SetDefaults() { - item.damage = 150; + item.damage = 315; item.ranged = true; item.width = 54; item.height = 92; - item.useTime = item.useAnimation = 16; + item.useTime = 5; + item.useAnimation = 20; + item.reuseDelay = 23; + item.knockBack = 7.5f; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; - item.knockBack = 4f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item5; + + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + + item.UseSound = SoundID.Item102; item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 18f; item.useAmmo = AmmoID.Arrow; } + public override Vector2? HoldoutOffset() => new Vector2(-14f, 0f); + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - Vector2 velocity = new Vector2(speedX, speedY).SafeNormalize(Vector2.UnitX * player.direction) * 30f; - bool willHitTiles = Collision.CanHit(position, 0, 0, position + velocity, 0, 0); - for (int i = 0; i < RayCount; i++) - { - Vector2 offset = velocity.RotatedBy(MathHelper.Pi * (i - (RayCount - 1f) / 2f) * 0.18f, default); - - // Go back if the spawn position and offset spawn position have an obstacle to prevent arrows from appearing - // behind walls the player cannot access. - if (!willHitTiles) - offset -= velocity; + // Always fires Radiant Arrows regardless of ammo used + type = item.shoot; - Projectile.NewProjectile(position + offset, new Vector2(speedX, speedY), item.shoot, damage, knockBack, player.whoAmI); - } - - return false; + // The arrow appears from a random location "on the bow". + // They are also moved backwards so that they have some time to build up past positions. This helps make them not appear out of thin air. + Vector2 velocity = new Vector2(speedX, speedY); + Vector2 offset = Vector2.Normalize(velocity.RotatedBy(MathHelper.PiOver2)); + position += offset * Main.rand.NextFloat(-19f, 19f); + position -= 3f * velocity; + return true; } } } diff --git a/Projectiles/Ranged/TelluricGlareArrow.cs b/Projectiles/Ranged/TelluricGlareArrow.cs new file mode 100644 index 0000000000..f23a879cc9 --- /dev/null +++ b/Projectiles/Ranged/TelluricGlareArrow.cs @@ -0,0 +1,135 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class TelluricGlareArrow : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public PrimitiveTrail TrailDrawer = null; + private const int Lifetime = 180; + private static Color ShaderColorOne = new Color(237, 194, 66); + private static Color ShaderColorTwo = new Color(235, 227, 117); + private static Color ShaderEndColor = new Color(199, 153, 26); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Radiant Arrow"); + // While this projectile doesn't have afterimages, it keeps track of old positions for its primitive drawcode. + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 21; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 24; + projectile.arrow = true; + projectile.friendly = true; + projectile.ranged = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = Lifetime; + projectile.MaxUpdates = 3; + projectile.penetrate = 2; // Can hit up to two enemies. Will explode extremely soon after hitting the first, though. + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; + } + + public override bool CanDamage() => projectile.timeLeft < Lifetime - 4; + + public override void AI() => Lighting.AddLight(projectile.Center, ShaderColorOne.ToVector3()); + + private void RestrictLifetime() + { + if (projectile.timeLeft > 8) + projectile.timeLeft = 8; + } + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + RestrictLifetime(); + target.AddBuff(ModContent.BuffType(), 240); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + RestrictLifetime(); + target.AddBuff(ModContent.BuffType(), 240); + } + + private float PrimitiveWidthFunction(float completionRatio) + { + float arrowheadCutoff = 0.36f; + float width = 39f; + float minHeadWidth = 0.02f; + float maxHeadWidth = width; + if (completionRatio <= arrowheadCutoff) + width = MathHelper.Lerp(minHeadWidth, maxHeadWidth, Utils.InverseLerp(0f, arrowheadCutoff, completionRatio, true)); + return width; + } + + private Color PrimitiveColorFunction(float completionRatio) + { + float endFadeRatio = 0.41f; + + float completionRatioFactor = 2.7f; + float globalTimeFactor = 5.3f; + float endFadeFactor = 3.2f; + float endFadeTerm = Utils.InverseLerp(0f, endFadeRatio * 0.5f, completionRatio, true) * endFadeFactor; + float cosArgument = completionRatio * completionRatioFactor - Main.GlobalTime * globalTimeFactor + endFadeTerm; + float startingInterpolant = (float)Math.Cos(cosArgument) * 0.5f + 0.5f; + + float colorLerpFactor = 0.6f; + Color startingColor = Color.Lerp(ShaderColorOne, ShaderColorTwo, startingInterpolant * colorLerpFactor); + + return Color.Lerp(startingColor, ShaderEndColor, MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(0f, endFadeRatio, completionRatio, true))); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]); + + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/TelluricGlareStreak")); + Vector2 overallOffset = projectile.Size * 0.5f - Main.screenPosition; + overallOffset += projectile.velocity * 1.4f; + TrailDrawer.Draw(projectile.oldPos, overallOffset, 92); // 58 + return false; + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item14, projectile.position); + + // Explode into a bunch of holy fire on death. + for (int i = 0; i < 10; i++) + { + Dust holyFire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); + holyFire.velocity *= 3f; + + if (Main.rand.NextBool(2)) + { + holyFire.scale = 0.5f; + holyFire.fadeIn = Main.rand.NextFloat(1f, 2f); + } + } + for (int i = 0; i < 20; i++) + { + Dust holyFire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 246, 0f, 0f, 100, default, 3f); + holyFire.noGravity = true; + holyFire.velocity *= 5f; + + holyFire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 246, 0f, 0f, 100, default, 2f); + holyFire.velocity *= 2f; + } + } + } +} diff --git a/Projectiles/Ranged/TelluricGlareProj.png b/Projectiles/Ranged/TelluricGlareArrow.png similarity index 100% rename from Projectiles/Ranged/TelluricGlareProj.png rename to Projectiles/Ranged/TelluricGlareArrow.png diff --git a/Projectiles/Ranged/TelluricGlareProj.cs b/Projectiles/Ranged/TelluricGlareProj.cs deleted file mode 100644 index 69f025f783..0000000000 --- a/Projectiles/Ranged/TelluricGlareProj.cs +++ /dev/null @@ -1,98 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class TelluricGlareProj : ModProjectile - { - public PrimitiveTrail TrailDrawer = null; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Glare"); - ProjectileID.Sets.TrailingMode[projectile.type] = 2; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 11; - } - - public override void SetDefaults() - { - projectile.width = projectile.height = 14; - projectile.arrow = true; - projectile.friendly = true; - projectile.ranged = true; - projectile.aiStyle = 1; - projectile.timeLeft = 180; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - } - - public float PrimitiveWidthFunction(float completionRatio) - { - float width; - if (completionRatio <= 0.23f) - width = MathHelper.SmoothStep(1f, projectile.width * 1.4f, Utils.InverseLerp(0f, 0.23f, completionRatio, true)); - else - { - width = MathHelper.SmoothStep(projectile.width * 2f, projectile.width, Utils.InverseLerp(0.18f, 0.29f, completionRatio, true)); - width *= Utils.InverseLerp(1f, 0.51f, completionRatio, true); - } - - return width; - } - - public Color PrimitiveColorFunction(float completionRatio) - { - float whiteFadeRequirement = 0.41f; - float startingInterpolant = (float)Math.Cos(completionRatio * 2.7f - Main.GlobalTime * 5.3f + Utils.InverseLerp(0f, whiteFadeRequirement * 0.5f, completionRatio, true) * 3.2f); - startingInterpolant = startingInterpolant * 0.5f + 0.5f; - Color startingColor = Color.Lerp(Color.Yellow, Color.OrangeRed, startingInterpolant * 0.6f); - return Color.Lerp(startingColor, Color.Wheat, MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(0f, whiteFadeRequirement, completionRatio, true))); - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (TrailDrawer is null) - TrailDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]); - - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/TelluricGlareStreak")); - TrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f - Main.screenPosition, 58); - return false; - } - - public override void Kill(int timeLeft) - { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 36); - Main.PlaySound(SoundID.Item14, projectile.position); - - // Explode into a bunch of holy fire on death. - for (int i = 0; i < 10; i++) - { - Dust holyFire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); - holyFire.velocity *= 3f; - - if (Main.rand.NextBool(2)) - { - holyFire.scale = 0.5f; - holyFire.fadeIn = Main.rand.NextFloat(1f, 2f); - } - } - for (int i = 0; i < 20; i++) - { - Dust holyFire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 246, 0f, 0f, 100, default, 3f); - holyFire.noGravity = true; - holyFire.velocity *= 5f; - - holyFire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 246, 0f, 0f, 100, default, 2f); - holyFire.velocity *= 2f; - } - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.AddBuff(ModContent.BuffType(), 120); - } -}