prim fix + whole line tweaks
This commit is contained in:
1 parent
975cc6b13d
commit
650d39d2d5
9 files changed
+287
-61
No files matched your search
@@ -322,7 +322,7 @@ namespace CalamityMod.Graphics.Primitives
|
||||
}
|
||||
|
||||
// Legacy behaviour: sample based on requested point count using Catmull-Rom style interpolation.
|
||||
PositionsIndex = 1;
|
||||
PositionsIndex = 0;
|
||||
float controlCountMinusOne = controlCount - 1f;
|
||||
PrimitiveSmoothingType legacyType = settings.SmoothingType;
|
||||
|
||||
@@ -344,8 +344,6 @@ namespace CalamityMod.Graphics.Primitives
|
||||
MainPositions[PositionsIndex] = EvaluateCurve(legacyType, p0, p1, p2, p3, localSplineInterpolant, settings);
|
||||
PositionsIndex++;
|
||||
}
|
||||
|
||||
MainPositions[0] = controlPoints[0];
|
||||
MainPositions[PositionsIndex] = controlPoints[controlCount - 1];
|
||||
PositionsIndex++;
|
||||
controlPoints.Clear();
|
||||
|
||||
@@ -309,7 +309,7 @@ namespace CalamityMod.Graphics.Primitives
|
||||
SmoothingTension = smoothingTension;
|
||||
FrameTransportMode = frameTransportMode;
|
||||
Topology = topology;
|
||||
CapStyle = PrimitiveCapStyle.Flat;
|
||||
CapStyle = capStyle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
using CalamityMod.Particles;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using CalamityMod.Graphics.Primitives;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
@@ -15,7 +18,12 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
public new string LocalizationCategory => "Projectiles.Rogue";
|
||||
public static int lifetime => 1200;
|
||||
Color? color = null;
|
||||
public override void SetStaticDefaults() => ProjectileID.Sets.CultistIsResistantTo[Type] = true;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.CultistIsResistantTo[Type] = true;
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 32;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
}
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 40;
|
||||
@@ -29,6 +37,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
Projectile.idStaticNPCHitCooldown = 10;
|
||||
Projectile.MaxUpdates = 2;
|
||||
Projectile.stopsDealingDamageAfterPenetrateHits = true;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
@@ -44,8 +53,6 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
Projectile.velocity += Projectile.DirectionTo(target.Center) * 2;
|
||||
Projectile.velocity *= 0.95f;
|
||||
color ??= Color.Lerp(Color.OrangeRed, new Color(255, 191, 73), Main.rand.NextFloat());
|
||||
GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center, Projectile.velocity * 0.001f, false, 10, 1, color.Value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,15 +61,9 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
if (Projectile.timeLeft < (lifetime - Projectile.ai[1]) && Projectile.ai[2] >= 0)
|
||||
{
|
||||
Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero);
|
||||
Projectile.velocity *= Projectile.ai[2];
|
||||
Projectile.velocity *= Projectile.ai[2];
|
||||
Projectile.ai[2]--;
|
||||
}
|
||||
if (Projectile.ai[2] > 0 && Projectile.velocity.Length() > 1)
|
||||
{
|
||||
|
||||
color ??= Color.Lerp(Color.OrangeRed, new Color(255, 191, 73), Main.rand.NextFloat());
|
||||
GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center, Projectile.velocity * 0.001f, false, 10, 1, color.Value));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -71,7 +72,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
if (Projectile.timeLeft > 100)
|
||||
Projectile.timeLeft = 100;
|
||||
Projectile.Center = Vector2.Lerp(Projectile.Center, Main.projectile[(int)Projectile.ai[0] - 1].Center, (1 - (Projectile.timeLeft / 100f)));
|
||||
Projectile.velocity *= 0f;
|
||||
Projectile.velocity = new(0, 1E-05f);
|
||||
if (Projectile.Distance(Main.projectile[(int)Projectile.ai[0] - 1].Center) < 16)
|
||||
{
|
||||
Main.projectile[(int)Projectile.ai[0] - 1].ai[2]++;
|
||||
@@ -91,10 +92,39 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
public override void OnKill(int timeLeft)
|
||||
{
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
Projectile.NewProjectile(Projectile.GetSource_Death(),Projectile.Center,Vector2.Zero,ModContent.ProjectileType<EclipseStealthBoom>(),Projectile.damage,Projectile.knockBack,Projectile.owner);
|
||||
Projectile.NewProjectile(Projectile.GetSource_Death(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType<EclipseStealthBoom>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
|
||||
}
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Main.spriteBatch.End(out var ss);
|
||||
var device = Main.instance.GraphicsDevice;
|
||||
using var lease = RenderTargetPool.Shared.Rent(
|
||||
device,
|
||||
Main.screenWidth / 2,
|
||||
Main.screenHeight / 2,
|
||||
RenderTargetDescriptor.Default
|
||||
);
|
||||
using (lease.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
var list = Projectile.oldPos.Take(16).ToArray();
|
||||
|
||||
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
|
||||
PrimitiveRenderer.RenderTrail(list, new(FireWidthFunction, FireColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), 32);
|
||||
|
||||
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
|
||||
PrimitiveRenderer.RenderTrail(list, new(FireCoreWidthFunction, FireCoreColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), 32);
|
||||
}
|
||||
float dis = Projectile.position.Distance(Projectile.oldPos.Last()) / 32;
|
||||
if (dis > 1)
|
||||
{
|
||||
dis = 1f;
|
||||
}
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.Transform);
|
||||
Main.spriteBatch.Draw(lease.Target, Vector2.Zero, null, Color.White * dis, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.spriteBatch.Begin(ss);
|
||||
|
||||
using (Main.spriteBatch.Scope())
|
||||
{
|
||||
Main.spriteBatch.Begin(default, BlendState.NonPremultiplied, null, null, null, null, Main.Transform);
|
||||
@@ -103,5 +133,51 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Matches Saros Possesion sunfire with slight edits
|
||||
public float FireWidthFunction(float completion, Vector2 vertexPos)
|
||||
{
|
||||
float width;
|
||||
float maxBodyWidth = 24f * Projectile.scale;
|
||||
float curveRatio = 0.2f;
|
||||
var positions = Projectile.oldPos.ToList();
|
||||
positions.RemoveAll(x => x == Vector2.Zero);
|
||||
if (completion < curveRatio)
|
||||
width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth;
|
||||
else
|
||||
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
|
||||
|
||||
// Pulse inwards and outwards over time.
|
||||
float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f;
|
||||
float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant);
|
||||
return (width + additionalPulseWidth) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
|
||||
}
|
||||
|
||||
public Color FireColorFunction(float completion, Vector2 vertexPos)
|
||||
{
|
||||
Color mainColor = new Color(238, 226, 153);
|
||||
return Color.Lerp(mainColor, Color.Transparent, completion);
|
||||
}
|
||||
|
||||
public float FireCoreWidthFunction(float completion, Vector2 vertexPos)
|
||||
{
|
||||
float width;
|
||||
float maxBodyWidth = Projectile.scale * 16;
|
||||
float curveRatio = 0.25f;
|
||||
var positions = Projectile.oldPos.ToList();
|
||||
positions.RemoveAll(x => x == Vector2.Zero);
|
||||
|
||||
if (completion < curveRatio)
|
||||
width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio;
|
||||
else
|
||||
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
|
||||
return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
|
||||
}
|
||||
|
||||
public Color FireCoreColorFunction(float completion, Vector2 vertexPos)
|
||||
{
|
||||
Color mainColor = new Color(255, 191, 73);
|
||||
return mainColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Particles;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using CalamityMod.Graphics.Primitives;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
@@ -12,6 +18,12 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
public static int lifetime = 150;
|
||||
Color? color = null;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 32;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
}
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 6;
|
||||
@@ -25,6 +37,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
Projectile.usesIDStaticNPCImmunity = true;
|
||||
Projectile.idStaticNPCHitCooldown = 10;
|
||||
Projectile.MaxUpdates = 2;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
@@ -36,47 +49,98 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
Projectile.velocity.Normalize();
|
||||
Projectile.velocity *= Projectile.localAI[0];
|
||||
Projectile.localAI[0]--;
|
||||
Projectile.timeLeft++;
|
||||
}
|
||||
|
||||
if (Projectile.localAI[0] == 0)
|
||||
{
|
||||
Projectile.Kill();
|
||||
Projectile.velocity = new(0, 1E-05f);
|
||||
Projectile.damage = 0;
|
||||
float dis = Projectile.position.Distance(Projectile.oldPos.Take(16).Last());
|
||||
if (dis < 0.1f)
|
||||
Projectile.Kill();
|
||||
}
|
||||
color ??= Color.Lerp(Color.OrangeRed, new Color(255, 191, 73),Main.rand.NextFloat());
|
||||
GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center,Projectile.velocity* 0.001f,false,10,1, color.Value));
|
||||
}
|
||||
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Collision.HitTiles(Projectile.position + Projectile.velocity, Projectile.velocity, Projectile.width, Projectile.height);
|
||||
Projectile.Kill();
|
||||
color ??= Color.Lerp(Color.OrangeRed, new Color(255, 191, 73), Main.rand.NextFloat(0.25f, 0.5f));
|
||||
|
||||
Main.spriteBatch.End(out var ss);
|
||||
var device = Main.instance.GraphicsDevice;
|
||||
using var lease = RenderTargetPool.Shared.Rent(
|
||||
device,
|
||||
Main.screenWidth / 2,
|
||||
Main.screenHeight / 2,
|
||||
RenderTargetDescriptor.Default
|
||||
);
|
||||
using (lease.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
var list = Projectile.oldPos.Take(16);
|
||||
|
||||
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
|
||||
PrimitiveRenderer.RenderTrail(list.ToArray(), new(FireWidthFunction, FireColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), 32);
|
||||
|
||||
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
|
||||
PrimitiveRenderer.RenderTrail(list.ToArray(), new(FireCoreWidthFunction, FireCoreColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), 32);
|
||||
}
|
||||
float dis = Projectile.position.Distance(Projectile.oldPos.Take(16).Last()) / 128f - 0.1f;
|
||||
if (dis > 1)
|
||||
{
|
||||
dis = 1f;
|
||||
}
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.Transform);
|
||||
Main.spriteBatch.Draw(lease.Target, Vector2.Zero, null, Color.White * dis, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.spriteBatch.Begin(ss);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnKill(int timeLeft)
|
||||
public float FireWidthFunction(float completion, Vector2 vertexPos)
|
||||
{
|
||||
return;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
int dustToUse = Main.rand.Next(0, 3);
|
||||
int dustType = 0;
|
||||
switch (dustToUse)
|
||||
{
|
||||
case 0:
|
||||
dustType = 109;
|
||||
break;
|
||||
case 1:
|
||||
dustType = 111;
|
||||
break;
|
||||
case 2:
|
||||
dustType = 132;
|
||||
break;
|
||||
}
|
||||
float width;
|
||||
float maxBodyWidth = 24f * Projectile.scale;
|
||||
float curveRatio = 0.2f;
|
||||
var positions = Projectile.oldPos.ToList();
|
||||
positions.RemoveAll(x => x == Vector2.Zero);
|
||||
if (completion < curveRatio)
|
||||
width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth;
|
||||
else
|
||||
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
|
||||
|
||||
int dust = Dust.NewDust(Projectile.Center, 1, 1, dustType, Projectile.velocity.X, Projectile.velocity.Y, 0, default, 1.5f);
|
||||
Main.dust[dust].noGravity = true;
|
||||
Main.dust[dust].velocity *= 0.75f;
|
||||
}
|
||||
// Pulse inwards and outwards over time.
|
||||
float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f;
|
||||
float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant);
|
||||
return (width + additionalPulseWidth) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
|
||||
}
|
||||
|
||||
public Color FireColorFunction(float completion, Vector2 vertexPos)
|
||||
{
|
||||
Color mainColor = new Color(255, 191, 73);
|
||||
return Color.Lerp(mainColor, Color.Transparent, completion);
|
||||
}
|
||||
|
||||
public float FireCoreWidthFunction(float completion, Vector2 vertexPos)
|
||||
{
|
||||
float width;
|
||||
float maxBodyWidth = Projectile.scale * 16;
|
||||
float curveRatio = 0.25f;
|
||||
var positions = Projectile.oldPos.ToList();
|
||||
positions.RemoveAll(x => x == Vector2.Zero);
|
||||
|
||||
if (completion < curveRatio)
|
||||
width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio;
|
||||
else
|
||||
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
|
||||
return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
|
||||
}
|
||||
|
||||
public Color FireCoreColorFunction(float completion, Vector2 vertexPos)
|
||||
{
|
||||
Color mainColor = color.Value;
|
||||
return mainColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,16 +93,16 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
|
||||
List<Vector2> posList = [];
|
||||
//For the prim to render properly I need to divide the distance between the positions into a couple points. Just using start and end doesn't render.
|
||||
for (var i = 0; i <= 10; i++)
|
||||
for (var i = 0; i <= 2; i++)
|
||||
{
|
||||
posList.Add(Vector2.Lerp(Projectile.position, LinePos.end, i / 10f));
|
||||
posList.Add(Vector2.Lerp(Projectile.position, LinePos.end, i / 2f));
|
||||
}
|
||||
var pos = posList.ToArray();
|
||||
|
||||
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
|
||||
PrimitiveRenderer.RenderTrail(pos, new(FireWidthFunction, FireColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), pos.Length + 32);
|
||||
PrimitiveRenderer.RenderTrail(pos, new(FireWidthFunction, FireColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), pos.Length);
|
||||
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/SylvestaffStreak"));
|
||||
PrimitiveRenderer.RenderTrail(pos, new(FireCoreWidthFunction, FireCoreColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), pos.Length + 24);
|
||||
PrimitiveRenderer.RenderTrail(pos, new(FireCoreWidthFunction, FireCoreColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), pos.Length);
|
||||
}
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
|
||||
@@ -34,7 +34,16 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
}
|
||||
|
||||
Projectile.velocity.X *= 0.975f;
|
||||
return true;
|
||||
var tile = Main.tile[(Projectile.Bottom + Vector2.UnitY).ToTileCoordinates()];
|
||||
if (tile.HasUnactuatedTile && tile.TileType == TileID.ConveyorBeltLeft)
|
||||
{
|
||||
Projectile.velocity.X = 2;
|
||||
}
|
||||
else if (tile.HasUnactuatedTile && tile.TileType == TileID.ConveyorBeltRight)
|
||||
{
|
||||
Projectile.velocity.X = -2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac)
|
||||
{
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Graphics.Primitives;
|
||||
using CalamityMod.Items.Weapons.Rogue;
|
||||
using CalamityMod.NPCs.Providence;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.Boss;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using CalamityMod.Utilities.Daybreak.Buffers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Graphics.PackedVector;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
@@ -25,6 +29,8 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
}
|
||||
public override void SetDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 8;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
Projectile.width = 20;
|
||||
Projectile.height = 20;
|
||||
Projectile.friendly = true;
|
||||
@@ -36,6 +42,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
Projectile.localNPCHitCooldown = 30;
|
||||
Projectile.timeLeft = 600;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.scale = 0.75f;
|
||||
}
|
||||
|
||||
public override bool? CanHitNPC(NPC target)
|
||||
@@ -51,6 +58,14 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
NPC target = null;
|
||||
public override void AI()
|
||||
{
|
||||
Projectile.frameCounter++;
|
||||
if (Projectile.frameCounter > 3)
|
||||
{
|
||||
Projectile.frame++;
|
||||
Projectile.frameCounter = 0;
|
||||
}
|
||||
if (Projectile.frame >= Main.projFrames[Type])
|
||||
Projectile.frame = 0;
|
||||
|
||||
if (Projectile.originalDamage == 0)
|
||||
{
|
||||
@@ -61,7 +76,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
Projectile.Calamity().HomingTarget = target.whoAmI;
|
||||
var dis = Projectile.Distance(target.Center);
|
||||
Projectile.velocity = Projectile.velocity.ToRotation().AngleLerp(Projectile.DirectionTo(target.Center).ToRotation(), (Projectile.Distance(target.Center) < 160 ? 0.1f + (1 - dis/160)*0.4f : 0.1f)).ToRotationVector2() * Projectile.velocity.Length();
|
||||
Projectile.velocity = Projectile.velocity.ToRotation().AngleLerp(Projectile.DirectionTo(target.Center).ToRotation(), (Projectile.Distance(target.Center) < 160 ? 0.1f + (1 - dis / 160) * 0.4f : 0.1f)).ToRotationVector2() * Projectile.velocity.Length();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -90,14 +105,61 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
SoundEngine.PlaySound(SoundID.DD2_BetsyFireballImpact.WithPitchOffset(0.6f), Projectile.Center);
|
||||
SoundEngine.PlaySound(SoundID.Item100.WithPitchOffset(0.4f), Projectile.Center);
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
|
||||
Main.spriteBatch.End(out var ss);
|
||||
var device = Main.instance.GraphicsDevice;
|
||||
using var lease = RenderTargetPool.Shared.Rent(
|
||||
device,
|
||||
Main.screenWidth / 2,
|
||||
Main.screenHeight / 2,
|
||||
RenderTargetDescriptor.Default
|
||||
);
|
||||
using (lease.Scope(clearColor: Color.Transparent))
|
||||
{
|
||||
var list = Projectile.oldPos.Take(8).ToList();
|
||||
|
||||
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
|
||||
PrimitiveRenderer.RenderTrail(list.ToArray(), new(FireWidthFunction, FireColorFunction, (_, _) => Projectile.Size * 0.5f, smoothen: true, pixelate: false, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"], useUnscaledMatrices: true), Projectile.oldPos.Length + 32);
|
||||
}
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.Transform);
|
||||
Main.spriteBatch.Draw(lease.Target, Vector2.Zero, null, Color.White * 0.75f, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.spriteBatch.Begin(ss);
|
||||
|
||||
Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
|
||||
var frame = tex.Frame(1, Main.projFrames[Type], 0, Projectile.frame);
|
||||
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, Color.White, Projectile.rotation, frame.Size() / 2f, Projectile.scale, SpriteEffects.None, 0);
|
||||
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, Color.White, Projectile.rotation, frame.Size() *0.5f, Projectile.scale, SpriteEffects.None, 0);
|
||||
return false;
|
||||
}
|
||||
public float FireWidthFunction(float completion, Vector2 pos)
|
||||
{
|
||||
float width;
|
||||
float maxBodyWidth = 16f * Projectile.scale;
|
||||
float curveRatio = 0.2f;
|
||||
var positions = Projectile.oldPos.ToList();
|
||||
positions.RemoveAll(x => x == Vector2.Zero);
|
||||
// Crop the tip of the trail into a conic shape.
|
||||
if (completion < curveRatio)
|
||||
width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth;
|
||||
else
|
||||
width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f);
|
||||
|
||||
// Pulse inwards and outwards over time.
|
||||
float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f;
|
||||
float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant);
|
||||
return (width + additionalPulseWidth) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type];
|
||||
}
|
||||
|
||||
public Color FireColorFunction(float completion, Vector2 pos)
|
||||
{
|
||||
Color mainColor = ProvUtils.GetProjectileColor(255);
|
||||
Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true));
|
||||
return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity;
|
||||
}
|
||||
|
||||
NPC GetTargetInRange(float range)
|
||||
{
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
public new string LocalizationCategory => "Projectiles.Rogue";
|
||||
public override void SetDefaults()
|
||||
{
|
||||
ProjectileID.Sets.TrailCacheLength[Type] = 6;
|
||||
ProjectileID.Sets.TrailingMode[Type] = 2;
|
||||
Projectile.width = 10;
|
||||
Projectile.height = 10;
|
||||
Projectile.friendly = true;
|
||||
@@ -23,6 +25,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
Projectile.usesLocalNPCImmunity = true;
|
||||
Projectile.localNPCHitCooldown = -1;
|
||||
Projectile.timeLeft = 600;
|
||||
Projectile.tileCollide = false;
|
||||
}
|
||||
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
||||
{
|
||||
@@ -77,7 +80,7 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Type].Value;
|
||||
Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0);
|
||||
CalamityUtils.DrawAfterimagesCentered(Projectile, 2, Color.White);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
@@ -96,9 +97,22 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
int shardCount = strongSplit ? 5 : 3;
|
||||
for (var i = 0; i < shardCount; i++)
|
||||
{
|
||||
var p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(0,-1).RotatedByRandom(1) * (strongSplit ? 10 : 7.5f), ModContent.ProjectileType<FossilShardThrown>(), 0 /*Shard dmg is set in its AI*/, Projectile.knockBack, Projectile.owner, 0f, 0f);
|
||||
var p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(0,-1).RotatedByRandom(1) * (strongSplit ? 10 : 7.5f) * Main.rand.NextFloat(0.9f,1.1f), ModContent.ProjectileType<FossilShardThrown>(), 0 /*Shard dmg is set in its AI*/, Projectile.knockBack, Projectile.owner, 0f, 0f);
|
||||
p.localNPCImmunity[target.whoAmI] = 30;
|
||||
}
|
||||
for (int i = 0; i < shardCount; i++)
|
||||
{
|
||||
int sparkLifetime = Main.rand.Next(8, 22);
|
||||
float sparkScale = Main.rand.NextFloat(0.5f, 1f);
|
||||
var sparkColor = Main.rand.NextBool() ? Color.DarkGoldenrod : Color.SandyBrown;
|
||||
|
||||
if (Main.rand.NextBool(5))
|
||||
sparkScale *= 1.4f;
|
||||
|
||||
Vector2 sparkVelocity = Vector2.UnitY.RotatedByRandom(1) * MathHelper.Lerp(-7.5f, -15, Main.rand.NextFloat());
|
||||
SparkParticle spark = new SparkParticle(target.Center, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor);
|
||||
GeneralParticleHandler.SpawnParticle(spark);
|
||||
}
|
||||
target.AddBuff(ModContent.BuffType<ArmorCrunch>(), 120);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user