Resprited Persecuted Enchantment demons
This commit is contained in:
1 parent
61add82f82
commit
c36d6ca3bb
9 files changed
+232
-20
No files matched your search
@@ -19,6 +19,7 @@ namespace CalamityMod.Effects
|
||||
public static Effect ScarletDevilShader;
|
||||
public static Effect BordernadoFireShader;
|
||||
public static Effect PrismCrystalShader;
|
||||
public static Effect ImpFlameTrailShader;
|
||||
public static Effect SCalShieldShader;
|
||||
|
||||
public static void LoadShaders()
|
||||
@@ -36,6 +37,7 @@ namespace CalamityMod.Effects
|
||||
PrismCrystalShader = CalamityMod.Instance.GetEffect("Effects/PrismCrystalStreak");
|
||||
FadedUVMapStreakShader = CalamityMod.Instance.GetEffect("Effects/FadedUVMapStreak");
|
||||
FadingSolidTrailShader = CalamityMod.Instance.GetEffect("Effects/FadingSolidTrail");
|
||||
ImpFlameTrailShader = CalamityMod.Instance.GetEffect("Effects/ImpFlameTrail");
|
||||
SCalShieldShader = CalamityMod.Instance.GetEffect("Effects/SupremeShieldShader");
|
||||
|
||||
Filters.Scene["CalamityMod:Astral"] = new Filter(new AstralScreenShaderData(new Ref<Effect>(AstralFogShader), "AstralPass").UseColor(0.18f, 0.08f, 0.24f), EffectPriority.VeryHigh);
|
||||
@@ -52,6 +54,7 @@ namespace CalamityMod.Effects
|
||||
GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"] = new MiscShaderData(new Ref<Effect>(ScarletDevilShader), "TrailPass");
|
||||
GameShaders.Misc["CalamityMod:Bordernado"] = new MiscShaderData(new Ref<Effect>(BordernadoFireShader), "TrailPass");
|
||||
GameShaders.Misc["CalamityMod:PrismaticStreak"] = new MiscShaderData(new Ref<Effect>(PrismCrystalShader), "TrailPass");
|
||||
GameShaders.Misc["CalamityMod:ImpFlameTrail"] = new MiscShaderData(new Ref<Effect>(ImpFlameTrailShader), "TrailPass");
|
||||
GameShaders.Misc["CalamityMod:SupremeShield"] = new MiscShaderData(new Ref<Effect>(SCalShieldShader), "ShieldPass");
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,64 @@
|
||||
sampler uImage0 : register(s0);
|
||||
sampler uImage1 : register(s1);
|
||||
float3 uColor;
|
||||
float3 uSecondaryColor;
|
||||
float uOpacity;
|
||||
float uSaturation;
|
||||
float uRotation;
|
||||
float uTime;
|
||||
float4 uSourceRect;
|
||||
float2 uWorldPosition;
|
||||
float uDirection;
|
||||
float3 uLightSource;
|
||||
float2 uImageSize0;
|
||||
float2 uImageSize1;
|
||||
matrix uWorldViewProjection;
|
||||
|
||||
struct VertexShaderInput
|
||||
{
|
||||
float4 Position : POSITION0;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Position : SV_POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
||||
{
|
||||
VertexShaderOutput output = (VertexShaderOutput)0;
|
||||
float4 pos = mul(input.Position, uWorldViewProjection);
|
||||
output.Position = pos;
|
||||
|
||||
output.Color = input.Color;
|
||||
output.TextureCoordinates = input.TextureCoordinates;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
// The X coordinate is the trail completion, the Y coordinate is the same as any other.
|
||||
// This is simply how the primitive TextCoord is layed out in the C# code.
|
||||
// Inputted images go into uImage1 sampler, in case you have a noise map or something similar.
|
||||
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||
{
|
||||
float4 color = input.Color;
|
||||
float2 coords = input.TextureCoordinates;
|
||||
// Fade out at the edges of the trail to give a blur effect.
|
||||
// This is very important.
|
||||
float flameStreakBrightness = tex2D(uImage1, float2(frac(coords.x - uTime * 2.9), coords.y)).r;
|
||||
float bloomOpacity = lerp(pow(sin(coords.y * 3.141), lerp(3, 10, coords.x)), 0.7, coords.x);
|
||||
return color * pow(bloomOpacity, 6.0) * lerp(2.0, 7, flameStreakBrightness);
|
||||
}
|
||||
|
||||
technique Technique1
|
||||
{
|
||||
pass TrailPass
|
||||
{
|
||||
VertexShader = compile vs_2_0 VertexShaderFunction();
|
||||
PixelShader = compile ps_2_0 PixelShaderFunction();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -59,12 +59,22 @@ namespace CalamityMod.NPCs.Other
|
||||
int demon = Projectile.NewProjectile(npc.Center, Main.rand.NextVector2CircularEdge(4f, 4f), ModContent.ProjectileType<SuicideBomberDemon>(), 17000, 0f, npc.target);
|
||||
if (Main.projectile.IndexInRange(demon))
|
||||
{
|
||||
Main.projectile[demon].ai[1] = Main.rand.Next(-10, 0);
|
||||
Main.projectile[demon].friendly = friendly;
|
||||
Main.projectile[demon].hostile = !friendly;
|
||||
Main.projectile[demon].netUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool? CanBeHitByProjectile(Projectile projectile)
|
||||
{
|
||||
if (projectile.type == ModContent.ProjectileType<SuicideBomberDemon>())
|
||||
return false;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit)
|
||||
{
|
||||
bool wouldDie = npc.life - (damage * (crit ? 2D : 1D)) <= 0;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
@@ -13,16 +16,18 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
get => projectile.ai[0] == 1f;
|
||||
set => projectile.ai[0] = value.ToInt();
|
||||
}
|
||||
public ref float Time => ref projectile.ai[1];
|
||||
public Player Owner => Main.player[projectile.owner];
|
||||
public PrimitiveTrail FlameTrailDrawer = null;
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Demon");
|
||||
Main.projFrames[projectile.type] = 5;
|
||||
Main.projFrames[projectile.type] = 12;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = projectile.height = 32;
|
||||
projectile.width = projectile.height = 48;
|
||||
projectile.tileCollide = false;
|
||||
projectile.ignoreWater = true;
|
||||
projectile.penetrate = -1;
|
||||
@@ -46,18 +51,24 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 2;
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 11;
|
||||
Time++;
|
||||
|
||||
// Decide an owner if necessary.
|
||||
if (projectile.owner == 255)
|
||||
projectile.owner = Player.FindClosest(projectile.Center, 1, 1);
|
||||
projectile.Opacity = MathHelper.Clamp(projectile.Opacity + 0.025f, 0f, 1f);
|
||||
|
||||
projectile.frame = projectile.frameCounter++ / 5 % Main.projFrames[projectile.type];
|
||||
// Rapidly fade in.
|
||||
projectile.Opacity = MathHelper.Clamp(projectile.Opacity + 0.025f, 0f, 1f);
|
||||
|
||||
// Anti-clumping behavior.
|
||||
float pushForce = 0.08f;
|
||||
for (int k = 0; k < Main.maxProjectiles; k++)
|
||||
{
|
||||
Projectile otherProj = Main.projectile[k];
|
||||
// Short circuits to make the loop as fast as possible
|
||||
|
||||
// Short circuits to make the loop as fast as possible.
|
||||
if (!otherProj.active || otherProj.type != projectile.type || k == projectile.whoAmI)
|
||||
continue;
|
||||
|
||||
@@ -78,33 +89,98 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
}
|
||||
}
|
||||
|
||||
if (projectile.hostile)
|
||||
Entity target = Owner;
|
||||
float attackFlySpeed = 18.5f;
|
||||
float flyInertia = 25f;
|
||||
if (projectile.friendly)
|
||||
{
|
||||
projectile.velocity = projectile.velocity.MoveTowards(projectile.SafeDirectionTo(Owner.Center) * 16f, 1.4f);
|
||||
projectile.spriteDirection = (Owner.Center.X > projectile.Center.X).ToDirectionInt();
|
||||
|
||||
if (HasDamagedSomething && projectile.WithinRange(Owner.Center, Owner.Size.Length() * 0.25f))
|
||||
projectile.Kill();
|
||||
target = projectile.Center.ClosestNPCAt(1360f);
|
||||
attackFlySpeed = 26.75f;
|
||||
flyInertia = 8f;
|
||||
}
|
||||
else if (projectile.friendly)
|
||||
|
||||
// Nullify the target value if they're a dead player.
|
||||
else if (!Owner.active || Owner.dead)
|
||||
target = null;
|
||||
|
||||
int oldSpriteDirection = projectile.spriteDirection;
|
||||
|
||||
// Rise upward somewhat slowly and flap wings.
|
||||
if (Time < 45f)
|
||||
{
|
||||
NPC potentialTarget = projectile.Center.ClosestNPCAt(1360f);
|
||||
if (potentialTarget is null)
|
||||
projectile.velocity = Vector2.Lerp(projectile.velocity, -Vector2.UnitY * 10f, 0.06f);
|
||||
else
|
||||
projectile.velocity = Vector2.Lerp(projectile.velocity, -Vector2.UnitY * 5f, 0.06f);
|
||||
if (projectile.frameCounter >= 6)
|
||||
{
|
||||
projectile.spriteDirection = (potentialTarget.Center.X > projectile.Center.X).ToDirectionInt();
|
||||
projectile.velocity = projectile.velocity.MoveTowards(projectile.SafeDirectionTo(potentialTarget.Center) * 18.5f, 3f);
|
||||
projectile.friendly = true;
|
||||
projectile.frame = (projectile.frame + 1) % 5;
|
||||
projectile.frameCounter = 0;
|
||||
}
|
||||
}
|
||||
else if (Time < 90f)
|
||||
{
|
||||
// Slow down.
|
||||
projectile.velocity = projectile.velocity.MoveTowards(Vector2.Zero, 0.4f) * 0.95f;
|
||||
|
||||
// Handle frames.
|
||||
projectile.frame = (int)Math.Round(MathHelper.Lerp(5f, 10f, Utils.InverseLerp(45f, 90f, Time, true)));
|
||||
|
||||
// And look at the target.
|
||||
float idealAngle = target is null ? 0f : projectile.AngleTo(target.Center);
|
||||
projectile.spriteDirection = target is null ? 1 : (target.Center.X > projectile.Center.X).ToDirectionInt();
|
||||
if (projectile.spriteDirection != oldSpriteDirection)
|
||||
projectile.rotation += MathHelper.Pi;
|
||||
|
||||
if (projectile.spriteDirection == -1)
|
||||
idealAngle += MathHelper.Pi;
|
||||
projectile.rotation = projectile.rotation.AngleTowards(idealAngle, 0.3f).AngleLerp(idealAngle, 0.08f);
|
||||
|
||||
if (Time == 75f)
|
||||
Main.PlaySound(SoundID.DD2_WyvernScream, projectile.Center);
|
||||
|
||||
// Reset the oldPos array in anticipation of a trail being drawn during the fly phase.
|
||||
projectile.oldPos = new Vector2[projectile.oldPos.Length];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (Time == 90f)
|
||||
Main.PlaySound(SoundID.DD2_WyvernDiveDown, projectile.Center);
|
||||
|
||||
projectile.frame = Main.projFrames[projectile.type] - 1;
|
||||
|
||||
// Fly away if no valid target was found.
|
||||
if (target is null)
|
||||
projectile.velocity = -Vector2.UnitY * 18f;
|
||||
|
||||
// Otherwise fly towards the target.
|
||||
else
|
||||
projectile.velocity = (projectile.velocity * (flyInertia - 1f) + projectile.SafeDirectionTo(target.Center) * attackFlySpeed) / flyInertia;
|
||||
|
||||
projectile.spriteDirection = (projectile.velocity.X > 0f).ToDirectionInt();
|
||||
projectile.rotation = CalamityUtils.WrapAngle90Degrees(projectile.velocity.ToRotation());
|
||||
if (target is null)
|
||||
{
|
||||
projectile.spriteDirection = 1;
|
||||
projectile.rotation = projectile.velocity.ToRotation();
|
||||
}
|
||||
|
||||
if (HasDamagedSomething && projectile.WithinRange(potentialTarget.Center, potentialTarget.Size.Length() * 0.25f))
|
||||
// Die if something has been hit and the target is either gone or really close.
|
||||
if (HasDamagedSomething && (target is null || target == Owner || projectile.WithinRange(target.Center, target.Size.Length() * 0.4f)))
|
||||
projectile.Kill();
|
||||
}
|
||||
|
||||
if (target != null && !HasDamagedSomething && projectile.Center.ManhattanDistance(target.Center) < target.height)
|
||||
{
|
||||
HasDamagedSomething = true;
|
||||
projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
|
||||
projectile.frameCounter++;
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
Main.PlaySound(SoundID.DD2_KoboldExplosion, projectile.Center);
|
||||
for (int i = 0; i < 40; i++)
|
||||
{
|
||||
Dust explosion = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 267);
|
||||
@@ -121,6 +197,46 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
// Ensure damage is not absolutely obscene when hitting players.
|
||||
public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) => damage = 95;
|
||||
|
||||
public float FlameTrailWidthFunction(float completionRatio) => MathHelper.SmoothStep(21f, 8f, completionRatio);
|
||||
|
||||
public Color FlameTrailColorFunction(float completionRatio)
|
||||
{
|
||||
float trailOpacity = Utils.InverseLerp(0.8f, 0.27f, completionRatio, true);
|
||||
Color startingColor = Color.Lerp(Color.Cyan, Color.White, 0.4f);
|
||||
Color middleColor = Color.Lerp(Color.Orange, Color.Yellow, 0.3f);
|
||||
Color endColor = Color.Lerp(Color.Orange, Color.Red, 0.67f);
|
||||
return CalamityUtils.MulticolorLerp(completionRatio, startingColor, middleColor, endColor) * trailOpacity;
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
// Initialize the flame trail drawer.
|
||||
if (FlameTrailDrawer is null)
|
||||
FlameTrailDrawer = new PrimitiveTrail(FlameTrailWidthFunction, FlameTrailColorFunction, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]);
|
||||
|
||||
// Prepare the flame trail shader with its map texture.
|
||||
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak"));
|
||||
|
||||
Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Typeless/SuicideBomberDemon");
|
||||
if (projectile.friendly)
|
||||
texture = ModContent.GetTexture("CalamityMod/Projectiles/Typeless/SuicideBomberDemonFriendly");
|
||||
Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame);
|
||||
Vector2 drawPosition = projectile.Center - Main.screenPosition;
|
||||
SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||
|
||||
// Draw the flame trail once ready.
|
||||
if (Time >= 90f)
|
||||
{
|
||||
Vector2 trailOffset = projectile.Size * 0.5f;
|
||||
trailOffset += Vector2.UnitY.RotatedBy(projectile.rotation) * (float)Math.Abs(Math.Sin(projectile.rotation)) * 14f;
|
||||
FlameTrailDrawer.Draw(projectile.oldPos, trailOffset - Main.screenPosition, 61);
|
||||
}
|
||||
|
||||
// Draw the base sprite.
|
||||
spriteBatch.Draw(texture, drawPosition, frame, projectile.GetAlpha(lightColor), projectile.rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnHitPlayer(Player target, int damage, bool crit)
|
||||
{
|
||||
HasDamagedSomething = true;
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -72,6 +72,25 @@ namespace CalamityMod
|
||||
/// <param name="a">The first point.</param>
|
||||
/// <param name="b">The second point.</param>
|
||||
public static float ManhattanDistance(this Vector2 a, Vector2 b) => Math.Abs(a.X - b.X) + Math.Abs(a.Y - b.Y);
|
||||
|
||||
/// <summary>
|
||||
/// Wraps an angle between -90 and 90 degrees. If an angle goes past this rangle it'll loop back to the other end.
|
||||
/// </summary>
|
||||
/// <param name="theta"></param>
|
||||
/// <returns></returns>
|
||||
public static float WrapAngle90Degrees(float theta)
|
||||
{
|
||||
// Ensure that the angle starts off in the -180 to 180 degree range instead of the 0 to 360 degree range.
|
||||
if (theta > MathHelper.Pi)
|
||||
theta -= MathHelper.Pi;
|
||||
|
||||
if (theta > MathHelper.PiOver2)
|
||||
theta -= MathHelper.Pi;
|
||||
if (theta < -MathHelper.PiOver2)
|
||||
theta += MathHelper.Pi;
|
||||
|
||||
return theta;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the angular distance between two vectors based on dot product comparisons. This method ensures underlying normalization is performed safely.
|
||||
|
||||
Reference in new issue
Block a user