1 - Tesselations are emitted in triangular patterns and only emit one hitscan strike each.
2 - Hitscan strikes use a custom type of DirectStrike due to needing particular behavior and visuals. 3 - Improved dust of Nanoblack Reaper and finally fixed the scythe to be thrown head-first when thrown left. 4 - Added a new particle StaticGlowLine, which renders as a fixed glowing line between two arbitrary points. Its origin can move at will via velocity.
This commit is contained in:
1 parent
94ce916ae8
commit
236e7a5684
10 files changed
+286
-373
No files matched your search
@@ -11,10 +11,20 @@ using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Weapons.Rogue
|
||||
{
|
||||
// Deny me no longer!
|
||||
// Bleak, directionless slaughter.
|
||||
// A celebration of the vices that brought Her to this point.
|
||||
[LegacyName("NanoblackReaperMelee", "NanoblackReaperRogue")]
|
||||
public class NanoblackReaper : RogueWeapon, IHoldShiftTooltipItem
|
||||
{
|
||||
// Right triangles, and like triangles.
|
||||
internal const float PiOver3 = MathHelper.Pi / 3f;
|
||||
internal const float TwoPiOver3 = MathHelper.TwoPi / 3f;
|
||||
|
||||
internal static readonly Color NanoblackDustColor1 = new Color(52, 239, 184); // #34EFB8
|
||||
internal static readonly Color TesselationParticleColor = new Color(79, 240, 168); // 4FF0A8
|
||||
internal static readonly Color ZeroPointLineColor = new Color(24, 191, 160); // #1FBFA0
|
||||
internal static readonly Color ZeroPointImpactColor = new Color(31, 223, 128, 96); // #1FDF80
|
||||
|
||||
public bool ShowExtensionIndicator => false;
|
||||
public bool HasFlavorTooltip => true;
|
||||
public Color? TooltipExtensionColor => new Color(31, 223, 128); // #1FDF80
|
||||
|
||||
@@ -792,7 +792,7 @@ NanoblackReaper: {
|
||||
Tooltip:
|
||||
'''
|
||||
Throws a scythe which rapidly forms a swarm of nanoblack tesselations from hard light
|
||||
Nanoblack tesselations each emit four instantaneous zero-point energy strikes
|
||||
Nanoblack tesselations each emit an instantaneous zero-point energy strike
|
||||
Zero-point energy strikes have 180 armor penetration and will target bosses whenever possible
|
||||
Press <right> just as the scythe begins returning to carve through the enemy closest to your cursor at lightspeed
|
||||
Lightspeed carves have 180 armor penetration. If timed in a 6-frame window, they supercrit with +100% critical strike chance
|
||||
|
||||
@@ -180,7 +180,7 @@ MoonSigil.DisplayName: Moon Sigil
|
||||
MycorootProj.DisplayName: Mycoroot
|
||||
MythrilKnifeProjectile.DisplayName: Mythril Knife
|
||||
NanoblackMain.DisplayName: Nanoblack Reaper
|
||||
NanoblackStealthSplit.DisplayName: Nanoblack Afterimage
|
||||
NanoblackStrike.DisplayName: Zero-Point Energy Strike
|
||||
NanoblackTesselation.DisplayName: Nanoblack Tesselation
|
||||
NastyChollaBol.DisplayName: Nasty Cholla
|
||||
NastyChollaNeedle.DisplayName: Cactus Needle
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Particles
|
||||
{
|
||||
public class StaticGlowLine : Particle
|
||||
{
|
||||
internal Asset<Texture2D> texAsset;
|
||||
// 1660 / 2048 is the size of the actual spark on the asset, roughly.
|
||||
private const float approximateSparkHeight = 1660f;
|
||||
|
||||
internal Vector2 destination;
|
||||
internal Color InitialColor;
|
||||
internal bool usesGlow;
|
||||
internal float xScale = 1f;
|
||||
internal float xShrink = 0.99f;
|
||||
private float currentYScale = 1f;
|
||||
|
||||
public override bool SetLifetime => true;
|
||||
public override bool UseCustomDraw => true;
|
||||
public override bool UseAdditiveBlend => true;
|
||||
|
||||
public override string Texture => "CalamityMod/Particles/GlowSpark";
|
||||
|
||||
public StaticGlowLine(Vector2 start, Vector2 dest, Vector2 velocity, int lifetime, float xScale, float xShrink, Color color, bool glow = true)
|
||||
{
|
||||
Position = start;
|
||||
destination = dest;
|
||||
Velocity = velocity;
|
||||
Lifetime = lifetime;
|
||||
|
||||
Scale = 1f; // unused for this particle
|
||||
this.xScale = xScale;
|
||||
this.xShrink = xShrink;
|
||||
|
||||
Color = InitialColor = color;
|
||||
usesGlow = glow;
|
||||
|
||||
Rotation = (dest - start).ToRotation() + MathHelper.PiOver2;
|
||||
texAsset = ModContent.Request<Texture2D>(Texture);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
// Color lerping to transparent matches the behavior of Glow Sparks.
|
||||
Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D));
|
||||
|
||||
// Line shrinks horizontally continuously while existing.
|
||||
xScale *= xShrink;
|
||||
|
||||
// Recalculate current Y scale every frame.
|
||||
Vector2 delta = destination - Position;
|
||||
currentYScale = delta.Length() / approximateSparkHeight;
|
||||
|
||||
// The Glow Spark asset is vertically oriented.
|
||||
// However, this particle's velocity and orientation are completely independent of one another.
|
||||
Rotation = (destination - Position).ToRotation() + MathHelper.PiOver2;
|
||||
}
|
||||
|
||||
public override void CustomDraw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Texture2D texture = texAsset.Value;
|
||||
Vector2 texSize = texture.Size() * 0.5f;
|
||||
Vector2 scaleThisFrame = new(xScale, currentYScale);
|
||||
|
||||
// Adjust the origin towards the target to compensate for the empty edges of the Glow Spark texture.
|
||||
// Add a little extra so the edges of the beam go through the source and destination slightly.
|
||||
float adjustmentDistance = 2f * currentYScale * (texture.Height - approximateSparkHeight);
|
||||
Vector2 toDest = (destination - Position).SafeNormalize(-Vector2.UnitY);
|
||||
Vector2 drawPos = Position + toDest * adjustmentDistance - Main.screenPosition;
|
||||
|
||||
spriteBatch.Draw(texture, drawPos, null, Color, Rotation, texSize, scaleThisFrame, 0, 0f);
|
||||
|
||||
if (usesGlow)
|
||||
{
|
||||
float glowInteriorWidth = 0.45f;
|
||||
Vector2 glowScale = new(glowInteriorWidth, 1f);
|
||||
spriteBatch.Draw(texture, drawPos, null, Color.White, Rotation, texSize, scaleThisFrame * glowScale, 0, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using CalamityMod.Dusts;
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
@@ -17,7 +19,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
private static int InternalLifetime => Lifetime * UpdatesPerFrame;
|
||||
private const float BoomerangReturnTime = 16f;
|
||||
|
||||
private const int BaseTesselationDelay = 6;
|
||||
private const int BaseTesselationDelay = 4;
|
||||
private static int InternalTesselationDelay => BaseTesselationDelay * UpdatesPerFrame;
|
||||
private const float TesselationSpawnSpeed = 24f;
|
||||
|
||||
@@ -116,7 +118,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
if (!Main.rand.NextBool(UpdatesPerFrame))
|
||||
return;
|
||||
|
||||
int dustType = Main.rand.NextBool(5) ? DustID.Electric : 220 /* no DustID entry */;
|
||||
int dustType = Main.rand.NextBool(5) ? ModContent.DustType<VoidDust>() : ModContent.DustType<VoidDustInverted>();
|
||||
|
||||
Vector2 position = Main.rand.NextVector2FromRectangle(Projectile.Hitbox);
|
||||
float scale = Main.rand.NextFloat(0.8f, 1.1f);
|
||||
@@ -126,6 +128,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
if (d is null || d.dustIndex == Main.maxDust)
|
||||
return;
|
||||
|
||||
d.color = NanoblackReaper.NanoblackDustColor1;
|
||||
d.noGravity = true;
|
||||
d.velocity = velocityMult * Projectile.velocity;
|
||||
}
|
||||
@@ -165,13 +168,16 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
Projectile.Kill();
|
||||
}
|
||||
|
||||
// Spawns an individual Nanoblack Tesselation.
|
||||
// Tesselations emit from the blade of the scythe and fly directly away, rapidly coming to a halt.
|
||||
// Spawns a triangular lattice of three Nanoblack Tesselations. All tesselations emit from the blade of the scythe.
|
||||
private void SpawnTesselation()
|
||||
{
|
||||
// Each tesselation randomly chooses which of its four zero-point energy strikes to fire first.
|
||||
// For consistent RNG across clients, this randomness is executed even if the result is not used.
|
||||
float zeroPointStrikeIndex = Main.rand.Next(4); // 0f, 1f, 2f or 3f
|
||||
int numTessSpawns = 3;
|
||||
|
||||
// Each tesselation spawns with a random delay before it chooses to fire.
|
||||
// For consistent RNG iteration, these RNG values are obtained even if they are not needed.
|
||||
static float GetStrikeDelay() => Main.rand.NextFloat(NanoblackTesselation.MinDelay, NanoblackTesselation.MaxDelay);float[] zeroPointStrikeDelays = new float[numTessSpawns];
|
||||
for (int i = 0; i < numTessSpawns; ++i)
|
||||
zeroPointStrikeDelays[i] = GetStrikeDelay();
|
||||
|
||||
if (Main.myPlayer != Projectile.owner)
|
||||
return;
|
||||
@@ -181,24 +187,36 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
float tessKB = 1.5f;
|
||||
|
||||
// The blade of Nanoblack Reaper is close enough to straight-right +X that using the rotation directly is fine.
|
||||
float scytheBladeRotation = Projectile.rotation;
|
||||
float scytheBladeRotation = Projectile.rotation * Projectile.spriteDirection;
|
||||
Vector2 spawnOffsetDir = scytheBladeRotation.ToRotationVector2();
|
||||
Vector2 tessPos = Projectile.Center + spawnOffsetDir * 14f;
|
||||
Vector2 tessVelDir = spawnOffsetDir.RotatedBy(-MathHelper.PiOver4); // close enough to a blade-egress vector
|
||||
Vector2 tessVel = tessVelDir * TesselationSpawnSpeed;
|
||||
Vector2 tessBaseVel = tessVelDir * TesselationSpawnSpeed;
|
||||
|
||||
var source = Projectile.GetSource_FromThis();
|
||||
int tessIdx = Projectile.NewProjectile(source, tessPos, tessVel, tessID, tessDamage, tessKB, Projectile.owner, ai1: zeroPointStrikeIndex);
|
||||
|
||||
// The spin direction of the scythe transfers to the tesselations.
|
||||
if (tessIdx.WithinBounds(Main.maxProjectiles))
|
||||
Main.projectile[tessIdx].direction = Projectile.direction;
|
||||
for (int i = 0; i < numTessSpawns; ++i)
|
||||
{
|
||||
Vector2 tessVel = tessBaseVel.RotatedBy(i * NanoblackReaper.TwoPiOver3);
|
||||
float delay = zeroPointStrikeDelays[i];
|
||||
int tessIdx = Projectile.NewProjectile(source, tessPos, tessVel, tessID, tessDamage, tessKB, Projectile.owner, ai0: delay);
|
||||
|
||||
// The spin direction of the scythe transfers to the tesselations.
|
||||
if (tessIdx.WithinBounds(Main.maxProjectiles))
|
||||
{
|
||||
Projectile tess = Main.projectile[tessIdx];
|
||||
tess.direction = tess.spriteDirection = Projectile.spriteDirection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RotateScytheInFlight()
|
||||
{
|
||||
float spin = Projectile.direction <= 0 ? -1f : 1f;
|
||||
Projectile.rotation += spin * RotationIncrement;
|
||||
|
||||
// When thrown left, Nanoblack Reaper is still thrown scythe-head first.
|
||||
Projectile.spriteDirection = Projectile.direction;
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
|
||||
@@ -1,206 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class NanoblackStealthSplit : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Rogue";
|
||||
public override string Texture => "CalamityMod/Items/Weapons/Rogue/NanoblackReaper";
|
||||
|
||||
private static int Lifetime = 300;
|
||||
private static float MaxSpeed = 40f;
|
||||
private static float MaxRotationSpeed = 0.25f;
|
||||
|
||||
private static float HomingStartRange = 4000f;
|
||||
private static float HomingBreakRange = 6000f;
|
||||
private static float HomingBonusRangeCap = 2000f;
|
||||
private static float BaseHomingFactor = 2.6f;
|
||||
private static float MaxHomingFactor = 8.6f;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.CultistIsResistantTo[Type] = true;
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 7;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 56;
|
||||
Projectile.height = 56;
|
||||
Projectile.friendly = true;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.penetrate = 12;
|
||||
Projectile.extraUpdates = 1;
|
||||
Projectile.timeLeft = Lifetime;
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = 8;
|
||||
Projectile.DamageType = RogueDamageClass.Instance;
|
||||
}
|
||||
|
||||
// ai[0] = Index of current NPC target. If 0 or negative, the projectile has no target
|
||||
// ai[1] = Current spin speed. When it reaches 0, starts homing into enemies. Negative speeds are also allowed.
|
||||
public override void AI()
|
||||
{
|
||||
|
||||
// Produces electricity and green firework sparks constantly while in flight. (Like the main projectile)
|
||||
if (Main.rand.NextBool(3))
|
||||
{
|
||||
int dustType = Main.rand.NextBool(5) ? 226 : 220;
|
||||
float scale = 0.8f + Main.rand.NextFloat(0.3f);
|
||||
float velocityMult = Main.rand.NextFloat(0.3f, 0.6f);
|
||||
int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType);
|
||||
Main.dust[idx].noGravity = true;
|
||||
Main.dust[idx].velocity = velocityMult * Projectile.velocity;
|
||||
Main.dust[idx].scale = scale;
|
||||
}
|
||||
|
||||
// Spin in the specified starting direction and slow down spin over time
|
||||
// Loses 1.66% of current speed every frame
|
||||
// Also update current orientation to reflect current spin direction
|
||||
if (Projectile.timeLeft > 200)
|
||||
{
|
||||
float currentSpin = Projectile.ai[1];
|
||||
Projectile.direction = currentSpin <= 0f ? -1 : 1;
|
||||
Projectile.spriteDirection = Projectile.direction;
|
||||
Projectile.rotation += currentSpin * MaxRotationSpeed;
|
||||
float spinReduction = 0.0166f * currentSpin;
|
||||
Projectile.ai[1] -= spinReduction;
|
||||
}
|
||||
// Search for and home in on nearby targets after the given time, and stops spinning
|
||||
else
|
||||
{
|
||||
Projectile.rotation = 0f;
|
||||
HomingAI();
|
||||
}
|
||||
}
|
||||
|
||||
private void HomingAI()
|
||||
{
|
||||
// If we don't currently have a target, go try and get one!
|
||||
int targetID = (int)Projectile.ai[0] - 1;
|
||||
if (targetID < 0)
|
||||
targetID = AcquireTarget();
|
||||
|
||||
// Save the target, whether we have one or not.
|
||||
Projectile.ai[0] = targetID + 1f;
|
||||
|
||||
// If we don't have a target, then just slow down a bit.
|
||||
if (targetID < 0)
|
||||
{
|
||||
Projectile.velocity *= 0.94f;
|
||||
return;
|
||||
}
|
||||
|
||||
// Homing behavior depends on how far the blade is from its target.
|
||||
NPC target = Main.npc[targetID];
|
||||
float xDist = Projectile.Center.X - target.Center.X;
|
||||
float yDist = Projectile.Center.Y - target.Center.Y;
|
||||
float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist);
|
||||
|
||||
// If the target is too far away, stop homing in on it.
|
||||
if (dist > HomingBreakRange)
|
||||
{
|
||||
Projectile.ai[0] = 0f;
|
||||
return;
|
||||
}
|
||||
|
||||
// Adds a multiple of the towards-target vector to its velocity every frame.
|
||||
float homingFactor = CalcHomingFactor(dist);
|
||||
Vector2 posDiff = target.Center - Projectile.Center;
|
||||
posDiff = posDiff.SafeNormalize(Vector2.Zero);
|
||||
posDiff *= homingFactor;
|
||||
Vector2 newVelocity = Projectile.velocity += posDiff;
|
||||
|
||||
// Caps speed to make sure it doesn't go too fast.
|
||||
if (newVelocity.Length() >= MaxSpeed)
|
||||
{
|
||||
newVelocity = newVelocity.SafeNormalize(Vector2.Zero);
|
||||
newVelocity *= MaxSpeed;
|
||||
}
|
||||
|
||||
Projectile.velocity = newVelocity;
|
||||
|
||||
//The afterimage's blade always tries to face its target
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(45f);
|
||||
}
|
||||
|
||||
// Returns the ID of the NPC to be targeted by this energy blade.
|
||||
// It chooses the closest target which can be chased, ignoring invulnerable NPCs.
|
||||
// Nanoblack Afterimages prefer to target bosses whenever possible.
|
||||
private int AcquireTarget()
|
||||
{
|
||||
bool bossFound = false;
|
||||
int target = -1;
|
||||
float minDist = HomingStartRange;
|
||||
foreach (NPC npc in Main.ActiveNPCs)
|
||||
{
|
||||
if (npc.type == NPCID.TargetDummy)
|
||||
continue;
|
||||
|
||||
// If we've found a valid boss target, ignore ALL targets which aren't bosses.
|
||||
if (bossFound && !npc.boss)
|
||||
continue;
|
||||
|
||||
if (npc.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float xDist = Projectile.Center.X - npc.Center.X;
|
||||
float yDist = Projectile.Center.Y - npc.Center.Y;
|
||||
float distToNPC = (float)Math.Sqrt(xDist * xDist + yDist * yDist);
|
||||
if (distToNPC < minDist)
|
||||
{
|
||||
// If this target within range is a boss, set the boss found flag.
|
||||
if (npc.boss)
|
||||
bossFound = true;
|
||||
minDist = distToNPC;
|
||||
target = npc.whoAmI;
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
// Afterimages home even more aggressively if they are very close to their target.
|
||||
private float CalcHomingFactor(float dist)
|
||||
{
|
||||
float baseFactor = BaseHomingFactor;
|
||||
float bonus = (MaxHomingFactor - BaseHomingFactor) * (1f - dist / HomingBonusRangeCap);
|
||||
if (bonus < 0f)
|
||||
bonus = 0f;
|
||||
return baseFactor + bonus;
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Spawns a tiny bit of dust when the afterimage vanishes.
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
SpawnDust();
|
||||
}
|
||||
|
||||
// Spawns a small bit of Luminite themed dust.
|
||||
private void SpawnDust()
|
||||
{
|
||||
int dustCount = Main.rand.Next(3, 6);
|
||||
Vector2 corner = Projectile.position;
|
||||
for (int i = 0; i < dustCount; ++i)
|
||||
{
|
||||
int dustType = 229;
|
||||
float scale = 0.6f + Main.rand.NextFloat(0.4f);
|
||||
int idx = Dust.NewDust(corner, Projectile.width, Projectile.height, dustType);
|
||||
Main.dust[idx].noGravity = true;
|
||||
Main.dust[idx].velocity *= 3f;
|
||||
Main.dust[idx].scale = scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
// 18NOV2024: Ozzatron: Nanoblack zero-point energy strikes are very similar to Direct Strikes, but aren't a subclass.
|
||||
// This is because they maintain a consistent offset and have visuals instead of having customized knockback.
|
||||
public class NanoblackStrike : ModProjectile, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Projectiles.Rogue";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
internal bool InvalidTarget => !((int)Projectile.ai[0]).WithinBounds(Main.maxNPCs);
|
||||
internal ref float visualXOffset => ref Projectile.ai[1];
|
||||
internal ref float visualYOffset => ref Projectile.ai[2];
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 2;
|
||||
Projectile.height = 2;
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = RogueDamageClass.Instance;
|
||||
Projectile.penetrate = 1;
|
||||
Projectile.extraUpdates = 0;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.alpha = 255;
|
||||
Projectile.timeLeft = 2;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => ProduceImpactParticles(target);
|
||||
public override void OnHitPlayer(Player target, Player.HurtInfo info) => ProduceImpactParticles(target);
|
||||
|
||||
private void ProduceImpactParticles(Entity target)
|
||||
{
|
||||
Vector2 visualsPos = Projectile.Center + new Vector2(Projectile.ai[1], Projectile.ai[2]);
|
||||
float sparkSpeed = 2f;
|
||||
// Spark particles invert depending on the scythe's flight direction at the moment their parent tesselations were created.
|
||||
float baseRot = Projectile.spriteDirection * MathHelper.PiOver2;
|
||||
float scale = 0.014f;
|
||||
Color color = NanoblackReaper.ZeroPointImpactColor;
|
||||
|
||||
// Spawn a triangle of three sparks.
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
float rot = baseRot + i * NanoblackReaper.TwoPiOver3;
|
||||
Vector2 sparkVel = sparkSpeed * rot.ToRotationVector2();
|
||||
Vector2 squashStretch = new(1f, 0.3f);
|
||||
Particle spark = new GlowSparkParticle(visualsPos, sparkVel, false, 11, scale, color, squashStretch, true, false, 1.25f);
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.IO;
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using CalamityMod.Projectiles.Typeless;
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
@@ -20,27 +19,20 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
|
||||
private const int Lifetime = 60;
|
||||
private const int VanishTime = 12;
|
||||
internal const int MinDelay = 15;
|
||||
internal const int MaxDelay = 45;
|
||||
|
||||
private const float TargetingRange = 600f;
|
||||
private const float ZeroPointFiringRange = 2000f;
|
||||
private const int SuccessiveStrikeCooldown = 4;
|
||||
|
||||
// Rotation speed is inherited directly from the scythe.
|
||||
private const float StartingRotationIncrement = NanoblackMain.RotationIncrement * NanoblackMain.UpdatesPerFrame;
|
||||
private const float DriftSpeed = 0.8f;
|
||||
|
||||
private Player Owner => Main.player[Projectile.owner];
|
||||
|
||||
// Tesselations do not re-target unless their current target is out of their extensive range or is dead.
|
||||
internal ref float TargetIndexPlusOne => ref Projectile.ai[0];
|
||||
internal ref float ZeroPointStrikeIndex => ref Projectile.ai[1];
|
||||
// 0f = Spindown, 1f = Zero-Point Strikes, 2f = Vanishing
|
||||
internal ref float OverallState => ref Projectile.ai[2];
|
||||
internal ref float ZeroPointStrikeDelay => ref Projectile.localAI[0];
|
||||
internal ref float CurrentSpin => ref Projectile.localAI[1];
|
||||
|
||||
// Tesselations can fire a maximum of four zero-point energy strikes.
|
||||
private int zeroPointStrikesPerformed = 0;
|
||||
internal ref float ZeroPointStrikeDelay => ref Projectile.ai[0];
|
||||
internal ref float CurrentSpin => ref Projectile.ai[1];
|
||||
private bool IsVanishing => Projectile.timeLeft < VanishTime;
|
||||
|
||||
public override void Load() => Glow = ModContent.Request<Texture2D>(Texture + "Glow");
|
||||
|
||||
@@ -56,6 +48,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
Projectile.width = 32;
|
||||
Projectile.height = 32;
|
||||
Projectile.scale = 0.5f;
|
||||
Projectile.friendly = true;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.tileCollide = false;
|
||||
@@ -66,141 +59,89 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
Projectile.DamageType = RogueDamageClass.Instance;
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(Projectile.localAI[0]);
|
||||
// Spin is deterministic and not necessary to sync
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
float lai0 = reader.ReadSingle();
|
||||
Projectile.localAI[0] = lai0;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Projectile.timeLeft == Lifetime)
|
||||
FrameOneEffects();
|
||||
|
||||
UpdateOverallState();
|
||||
// Tesselations enable their owner's mouse listener so that the mouse state is synced.
|
||||
// This is necessary for their targeting algorithm.
|
||||
Owner.Calamity().mouseWorldListener = true;
|
||||
|
||||
// If the Tesselation cannot attack, then it immediately transitions to vanishing.
|
||||
bool shouldShutdown = false;
|
||||
if (!IsVanishing)
|
||||
shouldShutdown = AttemptZeroPointEnergyStrikeThisFrame();
|
||||
if (shouldShutdown)
|
||||
Projectile.timeLeft = VanishTime - 1;
|
||||
|
||||
ProcessSpin();
|
||||
|
||||
// Tesselations always screech to a near-halt during spindown, but drift gently afterwards to form a mesmerizing pattern.
|
||||
if (OverallState == 0f)
|
||||
if (!IsVanishing && Projectile.velocity.LengthSquared() > DriftSpeed * DriftSpeed)
|
||||
Projectile.velocity *= 0.75f;
|
||||
|
||||
if (OverallState == 1f)
|
||||
{
|
||||
// If the Tesselation cannot attack, then it immediately transitions to vanishing.
|
||||
bool shutdown = PerformZeroPointStrikesIfAble();
|
||||
if (shutdown)
|
||||
Projectile.timeLeft = VanishTime - 1;
|
||||
}
|
||||
|
||||
// If the tesselation is vanishing, shrink by 12% every frame
|
||||
if (OverallState == 2f)
|
||||
if (IsVanishing)
|
||||
Projectile.scale *= 0.88f;
|
||||
}
|
||||
|
||||
private void FrameOneEffects()
|
||||
{
|
||||
TargetIndexPlusOne = 0f; // no target
|
||||
OverallState = 0f; // Spindown
|
||||
ZeroPointStrikeDelay = 0f; // can fire instantly when primed
|
||||
// Sanity check the firing delay.
|
||||
if (ZeroPointStrikeDelay < MinDelay)
|
||||
ZeroPointStrikeDelay = MinDelay;
|
||||
else if (ZeroPointStrikeDelay > MaxDelay)
|
||||
ZeroPointStrikeDelay = MaxDelay;
|
||||
|
||||
CurrentSpin = StartingRotationIncrement;
|
||||
|
||||
// Dust is produced to visually flavor the spawning of the projectile.
|
||||
SpawnDust();
|
||||
}
|
||||
|
||||
private void UpdateOverallState()
|
||||
{
|
||||
// Tesselations enable their owner's mouse listener so that the mouse state is synced.
|
||||
// This is necessary for their targeting algorithm.
|
||||
Owner.Calamity().mouseWorldListener = true;
|
||||
|
||||
// When there is little time left, tesselations vanish even if they could still fire.
|
||||
if (OverallState == 1f && Projectile.timeLeft < VanishTime)
|
||||
OverallState = 2f;
|
||||
|
||||
// Otherwise, tesselations are primed to fire once they are not moving quickly.
|
||||
else if (OverallState == 0f && Projectile.velocity.LengthSquared() < DriftSpeed * DriftSpeed)
|
||||
{
|
||||
// TODO -- visual effects on first frame of being armed
|
||||
OverallState = 1f;
|
||||
}
|
||||
// Create particles to visually flavor the spawning of the projectile.
|
||||
CreationDestructionVFX();
|
||||
}
|
||||
|
||||
private void ProcessSpin()
|
||||
{
|
||||
// Visually spins the tesselation.
|
||||
float rotationIncrement = CurrentSpin * Projectile.direction;
|
||||
float rotationIncrement = CurrentSpin * Projectile.spriteDirection;
|
||||
Projectile.rotation += rotationIncrement;
|
||||
|
||||
// Spin slows down exponentially over time.
|
||||
CurrentSpin *= 0.93f;
|
||||
|
||||
// Always update current orientation to reflect current spin direction
|
||||
Projectile.spriteDirection = Projectile.direction;
|
||||
}
|
||||
|
||||
// Returns whether or not the Tesselation cannot attack and should shut down.
|
||||
private bool PerformZeroPointStrikesIfAble()
|
||||
// Returns whether or not the Tesselation should shut down.
|
||||
private bool AttemptZeroPointEnergyStrikeThisFrame()
|
||||
{
|
||||
// If the maximum number of zero-point strikes has been delivered, shut down the Tesselation.
|
||||
if (zeroPointStrikesPerformed >= 4)
|
||||
return true;
|
||||
|
||||
// Reduce the cooldown of the zero-point strikes, if applicable.
|
||||
// If the attack isn't ready yet, don't perform it.
|
||||
if (ZeroPointStrikeDelay > 0f)
|
||||
{
|
||||
--ZeroPointStrikeDelay;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the index of the NPC to target.
|
||||
int targetIdx = EvaluateTargeting();
|
||||
|
||||
// If there's no target, shut down the Tesselation.
|
||||
if (targetIdx == -2)
|
||||
// As is Nanoblack tradition, Tesselations prefer to target bosses whenever possible.
|
||||
bool inFiringRange = false;
|
||||
NPC target = Owner.ClampedMouseWorld().ClosestNPCAt(TargetingRange, bossPriority: true);
|
||||
|
||||
// If the first cursor-based targeting attempt fails, try again near the Tesselation itself.
|
||||
if (target is null || !target.active)
|
||||
target = Projectile.Center.ClosestNPCAt(TargetingRange, bossPriority: true);
|
||||
|
||||
// Check firing range. Tesselations can fire across a whole 1080p screen, but it's not infinite distance.
|
||||
if (target is not null && target.active)
|
||||
inFiringRange = target.DistanceSQ(Projectile.Center) < ZeroPointFiringRange * ZeroPointFiringRange;
|
||||
if (!inFiringRange)
|
||||
return true;
|
||||
|
||||
// At this point, the cooldown and targeting are confirmed.
|
||||
EmitZeroPointEnergyStrike(targetIdx);
|
||||
return false;
|
||||
// At this point, the targeting is confirmed. Emit the strike.
|
||||
EmitZeroPointEnergyStrike(target);
|
||||
return true;
|
||||
}
|
||||
|
||||
// As is Nanoblack tradition, Tesselations prefer to target bosses whenever possible.
|
||||
// Returns the index of the current target for convenience.
|
||||
// If it returns -2, targeting has failed and the Tesselation will shut down.
|
||||
private int EvaluateTargeting()
|
||||
private void EmitZeroPointEnergyStrike(NPC target)
|
||||
{
|
||||
// Check whether the current target is valid, alive, and in firing range.
|
||||
// If so, do nothing.
|
||||
int currentTargetIdx = (int)(TargetIndexPlusOne - 1);
|
||||
if (currentTargetIdx.WithinBounds(Main.maxNPCs))
|
||||
{
|
||||
NPC target = Main.npc[currentTargetIdx];
|
||||
if (target is not null && target.active && target.DistanceSQ(Projectile.Center) <= ZeroPointFiringRange * ZeroPointFiringRange)
|
||||
return currentTargetIdx;
|
||||
}
|
||||
|
||||
// Otherwise, choose a new target based on the player's current cursor position.
|
||||
NPC newTarget = Owner.ClampedMouseWorld().ClosestNPCAt(TargetingRange, bossPriority: true);
|
||||
if (newTarget is not null && newTarget.active)
|
||||
{
|
||||
// Store the target index.
|
||||
TargetIndexPlusOne = newTarget.whoAmI + 1;
|
||||
return newTarget.whoAmI;
|
||||
}
|
||||
|
||||
return -2;
|
||||
}
|
||||
|
||||
private void EmitZeroPointEnergyStrike(int targetIdx)
|
||||
{
|
||||
// Exact positioning of the zero-point energy strike is randomly chosen.
|
||||
// Exact visual offset of the zero-point energy strike is randomly chosen.
|
||||
// For consistent RNG across clients, this randomness is executed even if the result is not used.
|
||||
float xInterp = Main.rand.NextFloat();
|
||||
float yInterp = Main.rand.NextFloat();
|
||||
@@ -208,39 +149,47 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
if (Main.myPlayer != Projectile.owner)
|
||||
return;
|
||||
|
||||
NPC target = Main.npc[targetIdx];
|
||||
// The "dartboard" is the majority, but not all, of the NPC's hitbox.
|
||||
Vector2 c = target.Center;
|
||||
|
||||
float dartboardScale = 0.4f; // 0.5f would be the entire hitbox of the NPC
|
||||
Vector2 topLeft = c - dartboardScale * target.Size;
|
||||
Vector2 bottomRight = c + dartboardScale * target.Size;
|
||||
float dartboardX = MathHelper.Lerp(topLeft.X, bottomRight.X, xInterp);
|
||||
float dartboardY = MathHelper.Lerp(topLeft.Y, bottomRight.Y, yInterp);
|
||||
Vector2 strikeDest = new(dartboardX, dartboardY);
|
||||
Vector2 offset = strikeDest - c;
|
||||
|
||||
Vector2 directStrikeDest = new(MathHelper.Lerp(topLeft.X, bottomRight.X, xInterp), MathHelper.Lerp(topLeft.Y, bottomRight.Y, yInterp));
|
||||
|
||||
// zero-point energy strikes should probably be their own subclass of DirectStrike but not yet
|
||||
int zpeID = ModContent.ProjectileType<DirectStrike>();
|
||||
int zpeDamage = Projectile.damage; // same ratio as the tesselation itself
|
||||
int zpeID = ModContent.ProjectileType<NanoblackStrike>();
|
||||
int zpeDamage = Projectile.damage; // same damage ratio as the tesselation itself
|
||||
float zpeKB = 0f;
|
||||
|
||||
var source = Projectile.GetSource_FromThis();
|
||||
int zpeIdx = Projectile.NewProjectile(source, directStrikeDest, Vector2.Zero, zpeID, zpeDamage, zpeKB, Projectile.owner, targetIdx);
|
||||
int zpeIdx = Projectile.NewProjectile(source, strikeDest, Vector2.Zero, zpeID, zpeDamage, zpeKB, Projectile.owner, ai0: target.whoAmI, ai1: offset.X, ai2: offset.Y);
|
||||
if (zpeIdx.WithinBounds(Main.maxProjectiles))
|
||||
{
|
||||
Projectile zpe = Main.projectile[zpeIdx];
|
||||
zpe.ArmorPenetration += NanoblackReaper.ZeroPointArmorPenetration;
|
||||
zpe.ArmorPenetration += NanoblackReaper.ZeroPointArmorPenetration; // Add excessive armor penetration.
|
||||
|
||||
// This consistently orients the visuals of the hitscan attack for flair.
|
||||
zpe.direction = zpe.spriteDirection = Projectile.spriteDirection;
|
||||
}
|
||||
|
||||
// TODO -- visuals for zero-point energy strikes. This is where the visual strike index is used
|
||||
Dust.NewDustPerfect(directStrikeDest, 173);
|
||||
// Draw a bright line of energy between the Tesselation and the spawned strike.
|
||||
Vector2 lineVel = 3f * Projectile.velocity;
|
||||
float xScale = 0.009f;
|
||||
float xShrink = 0.88f;
|
||||
Color lineColor = NanoblackReaper.ZeroPointLineColor;
|
||||
Particle energyLine = new StaticGlowLine(Projectile.Center, strikeDest, lineVel, 7, xScale, xShrink, lineColor, true);
|
||||
GeneralParticleHandler.SpawnParticle(energyLine);
|
||||
|
||||
++zeroPointStrikesPerformed;
|
||||
|
||||
// Set the cooldown between strikes.
|
||||
ZeroPointStrikeDelay = SuccessiveStrikeCooldown + 6;
|
||||
|
||||
// Swap visual strike index. If it overflows, reset it back to zero.
|
||||
ZeroPointStrikeIndex += 1f;
|
||||
if (ZeroPointStrikeIndex > 3f)
|
||||
ZeroPointStrikeIndex = 0f;
|
||||
// Draw four stacked glow orbs right at the start of the line.
|
||||
// One glow orb was not glowy enough.
|
||||
float orbScale = 1.5f;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
Particle energyOrb = new GlowOrbParticle(Projectile.Center, lineVel, false, 15, orbScale, lineColor);
|
||||
GeneralParticleHandler.SpawnParticle(energyOrb);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
@@ -263,25 +212,20 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
Main.EntitySpriteDraw(Glow.Value, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, origin, Projectile.scale, eff, 0);
|
||||
}
|
||||
|
||||
// Spawns a tiny bit of dust when the tesselation vanishes.
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
SpawnDust();
|
||||
}
|
||||
public override void OnKill(int timeLeft) => CreationDestructionVFX(true);
|
||||
|
||||
// Spawns a small bit of Luminite themed dust.
|
||||
private void SpawnDust()
|
||||
private void CreationDestructionVFX(bool killed)
|
||||
{
|
||||
int dustCount = Main.rand.Next(3, 6);
|
||||
Vector2 corner = Projectile.position;
|
||||
for (int i = 0; i < dustCount; ++i)
|
||||
float sparkSpeed = 2f;
|
||||
float baseRot = MathHelper.PiOver2;
|
||||
float scale = 0.018f;
|
||||
Color color = NanoblackReaper.TesselationParticleColor;
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
int dustType = 229;
|
||||
float scale = 0.6f + Main.rand.NextFloat(0.4f);
|
||||
int idx = Dust.NewDust(corner, Projectile.width, Projectile.height, dustType);
|
||||
Main.dust[idx].noGravity = true;
|
||||
Main.dust[idx].velocity *= 3f;
|
||||
Main.dust[idx].scale = scale;
|
||||
float rot = baseRot + i * NanoblackReaper.PiOver3;
|
||||
Vector2 sparkVel = sparkSpeed * rot.ToRotationVector2();
|
||||
Vector2 squashStretch = new(1f, 0.3f);
|
||||
Particle p = new GlowSparkParticle(Projectile.Center, sparkVel, killed, 15, scale, color, squashStretch, true, true, 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,14 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
public new string LocalizationCategory => "Projectiles.Typeless";
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
public bool invalidTarget => (Projectile.ai[0] < 0f || Projectile.ai[0] > 199f);
|
||||
public Vector2 pushVelocity => new Vector2(Projectile.ai[1], Projectile.ai[2]);
|
||||
// You can set projectile.ai 1 & 2 to the x and y velocity that you would like to launch the target, even if the direct strike deals no damage
|
||||
|
||||
public bool hasStongDisplacement = false; // If you set Knockback to anything below zero, the custom knockback will be able to effect enemies that normally ignore knockback
|
||||
// You can set Projectile AI 1 & 2 to the X/Y velocity that you would like to launch the target, even if the direct strike deals no damage.
|
||||
// This lets Direct Strikes be used as "Direct Nudges" which deal no damage but push something around.
|
||||
public Vector2 pushVelocity => new(Projectile.ai[1], Projectile.ai[2]);
|
||||
|
||||
// If you set Knockback to anything below zero, the custom knockback will be able to effect enemies that normally ignore knockback
|
||||
public bool hasStongDisplacement = false;
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 2;
|
||||
@@ -25,6 +29,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
Projectile.alpha = 255;
|
||||
Projectile.timeLeft = 2;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Projectile.knockBack < 0)
|
||||
@@ -34,7 +39,7 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
}
|
||||
|
||||
// If the target is moving VERY fast, direct strikes spawned on top of them can actually miss
|
||||
// Setting a target will gaurentee hits on said target by teleporting the projectile onto them every frame
|
||||
// Setting a target will guarantee hits on said target by teleporting the projectile onto their center every frame
|
||||
if (!invalidTarget)
|
||||
Projectile.Center = Main.npc[(int)Projectile.ai[0]].Center;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Particles;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
|
||||
Reference in new issue
Block a user