Finished Telluric Glare rework.

This commit is contained in:
Ozzatron committed 2021-03-03 21:24:40 -05:00
1 parent 7374639ea1
commit e46fdd4357
4 files changed
+159 -122

No files matched your search

+24 -24
View File
@@ -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<TelluricGlareProj>();
item.shoot = ModContent.ProjectileType<TelluricGlareArrow>();
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;
}
}
}
+135
View File
@@ -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<HolyFlames>(), 240);
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
RestrictLifetime();
target.AddBuff(ModContent.BuffType<HolyFlames>(), 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;
}
}
}
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 347 B

After

Width:  |  Height:  |  Size: 347 B

-98
View File
@@ -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<HolyFlames>(), 120);
}
}