Files
CalamityModPublic/Projectiles/Melee/TrueBiomeBlade_GhastlyChain.cs
T
CongratsIsTrash 07845a7328 A massive amount of TBB shit
Mostly to resolve continuity issues resulting from BB changes

Swordsmith's Pride is now obtained from Hallow and Astral
Mercurial Tides is now obtained from Purity and sea biomes; renamed it to Earthen Tides

Swordsmith's Pride:
* Sword is still spun up as usual, but fires homing astral energies instead of sword beams
* Sword throw no longer spawns the sigil, but now spawns monoliths at its peak distance
* Number of monoliths scale with sword charge (50% = 1, 75% = 3, 100% = 5), and spawn in a fan shape
* Passive now makes attacks inflict Astral Infection instead of spawning sword beams

Earthen Tides:
* Keeps current core functionality of being a charge-up dash attack
* Now spawns homing sword beams while charging up instead of shockwaves
* Dash spawns the sigil on hit; sigil continuously inflicts Armor Crunch on the marked enemy and causes sword beam homing to prioritize the marked enemy
* Passive still spawns shockwaves; make them bigger, but hit less often
* TODO: Retheme tile collision monolith into rocky stalagmites
2024-07-15 23:39:44 -04:00

103 lines
4.3 KiB
C#

using System;
using CalamityMod.DataStructures;
using CalamityMod.Items.Weapons.Melee;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
namespace CalamityMod.Projectiles.Melee
{
public class GhastlyChain : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public override string Texture => "CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedChain";
public Player Owner => Main.player[Projectile.owner];
public float Timer => 20 - Projectile.timeLeft;
public float Gravity;
public NPC NPCfrom
{
get => Main.npc[(int)Projectile.ai[0]];
set => Projectile.ai[0] = value.whoAmI;
}
public NPC Target
{
get => Main.npc[(int)Projectile.ai[1]];
set => Projectile.ai[1] = value.whoAmI;
}
public override void SetStaticDefaults()
{
}
public override void SetDefaults()
{
Projectile.DamageType = DamageClass.Melee;
Projectile.width = Projectile.height = 8;
Projectile.tileCollide = false;
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 30;
Projectile.timeLeft = 20;
}
public override bool? CanHitNPC(NPC target) => target == Target;
public override void AI()
{
Projectile.Center = Target.Center;
}
public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
{
if (Owner.HeldItem.ModItem is OmegaBiomeBlade sword && Main.rand.NextFloat() <= OmegaBiomeBlade.FlailBladeAttunement_GhostChainProc)
sword.OnHitProc = true;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
if (Owner.HeldItem.ModItem is OmegaBiomeBlade sword && sword.secondaryAttunement.id == AttunementID.Whirlwind)
WhirlwindAttunement.RealPassiveEffect(target);
}
public override bool PreDraw(ref Color lightColor)
{
Texture2D chainTex = Request<Texture2D>("CalamityMod/Projectiles/Melee/TrueBiomeBlade_LamentationsOfTheChainedChain").Value;
//Turn on additive blending
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
float opacity = Projectile.timeLeft > 10 ? 1 : Projectile.timeLeft / 10f;
Vector2 Shake = Projectile.timeLeft < 15 ? Vector2.Zero : Vector2.One.RotatedByRandom(MathHelper.TwoPi) * (15 - Projectile.timeLeft / 5f) * 0.5f;
BezierCurve curve = new BezierCurve(new Vector2[] { Target.Center, Target.Center + Vector2.UnitY * Gravity, NPCfrom.Center + Vector2.UnitY * Gravity, NPCfrom.Center });
int numPoints = 20;
Vector2[] Nodes = curve.GetPoints(numPoints).ToArray();
for (int i = 1; i < numPoints; i++)
{
Vector2 position = Nodes[i] + Shake * (float)Math.Sin(i / (float)numPoints * MathHelper.Pi);
float rotation = (Nodes[i] - Nodes[i - 1]).ToRotation() - MathHelper.PiOver2; //Calculate rotation based on direction from last point
float yScale = Vector2.Distance(Nodes[i], Nodes[i - 1]) / chainTex.Height; //Calculate how much to squash/stretch for smooth chain based on distance between points
Vector2 scale = new Vector2(1, yScale);
Vector2 origin = new Vector2(chainTex.Width / 2, chainTex.Height); //Draw from center bottom of texture
Main.EntitySpriteDraw(chainTex, position - Main.screenPosition, null, Color.White * opacity, rotation, origin, scale, SpriteEffects.None, 0);
}
//Back to normal
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
return false;
}
}
}