scal arena visuals + minor hook fix + enrage fix

This commit is contained in:
doze-zoze authored and Cameron Ewell committed 2025-10-31 15:55:04 -04:00
1 parent d1d4735c3a
commit f6a4161184
11 files changed
+234 -40

No files matched your search

+3 -2
View File
@@ -6,6 +6,7 @@ float2 layerSize;
float2 layerOffset;
float4 edgeColor;
float2 singleFrameScreenOffset;
float4 layerColor;
// The usage of these two methods seemingly prevents imprecision problems for some reason.
float2 convertToScreenCoords(float2 coords)
@@ -43,8 +44,8 @@ float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD
float conditionOpacityFactor = 1 - saturate(leftHasNoAlpha + rightHasNoAlpha + topHasNoAlpha + bottomHasNoAlpha);
// Calculate layer colors.
float4 layerColor = tex2D(overlayTexture, (coords + layerOffset + singleFrameScreenOffset) * screenSize / layerSize);
float4 defaultColor = layerColor * tex2D(metaballContents, coords) * sampleColor;
float4 layerCalcedColor = tex2D(overlayTexture, (coords + layerOffset + singleFrameScreenOffset) * screenSize / layerSize);
float4 defaultColor = layerCalcedColor * tex2D(metaballContents, coords) * sampleColor * layerColor;
// Lastly, use the aforementioned condition to switch between the colors. If conditionOpacityFactor is 1, the default color is
// zeroed out and the edge is toggled, and vice versa.
Binary file not shown.
+7
View File
@@ -45,6 +45,12 @@ namespace CalamityMod.Graphics.Metaballs
{
get;
}
/// <summary>
/// Colors for the layers to draw with. Defaults to white when unset.
/// </summary>
public virtual List<Vector4> LayerColors { get; set; } = [];
/// <summary>
/// Whether the metaball runs Update based on the draw cycle or the game update cycle
/// </summary>
@@ -105,6 +111,7 @@ namespace CalamityMod.Graphics.Metaballs
metaballShader.Parameters["layerOffset"]?.SetValue(layerScrollOffset);
metaballShader.Parameters["edgeColor"]?.SetValue(EdgeColor.ToVector4());
metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue((Main.screenLastPosition - Main.screenPosition) / screenSize);
metaballShader.Parameters["layerColor"]?.SetValue(LayerColors.Count() > layerIndex ? LayerColors[layerIndex] : Color.White.ToVector4());
// Supply the metaball's layer texture to the graphics device so that the shader can read it.
gd.Textures[1] = layerTexture;
Binary file not shown.

After

Width:  |  Height:  |  Size: 439 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

+149
View File
@@ -0,0 +1,149 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CalamityMod.NPCs;
using CalamityMod.NPCs.SupremeCalamitas;
using CalamityMod.Systems.Mechanic;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.ModLoader;
using static CalamityMod.Graphics.Metaballs.StreamGougeMetaball;
using static CalamityMod.Systems.LavaRenderingSystem;
namespace CalamityMod.Graphics.Metaballs
{
public class ScalArenaMetaball : Metaball
{
public class Particle
{
public float Size;
public Vector2 Velocity;
public Vector2 Center;
public Texture2D TextureToUse = null;
public float rotation = 0;
public float SizeScaling = 0.85f;
public int CurrentFrame = 0;
public int MaxFrames = 1;
public Vector2 Scale = Vector2.One;
public int Age = 0;
public Particle(Vector2 center, Vector2 velocity, float size)
{
Center = center;
Velocity = velocity;
Size = size;
}
public void Update()
{
Age++;
Center += Velocity;
Velocity *= 0.96f;
if (Age > 1)
Size *= SizeScaling;
}
}
public override bool IgnoreFPS => true;
public static List<Particle> Particles
{
get;
private set;
} = new();
public override bool AnythingToDraw => Particles.Any();
private static Asset<Texture2D> MainLayer;
private static Texture2D WavyLineLayer; //Not wrapped in Asset<> as we need to edit the texutre post-loading.
public override IEnumerable<Texture2D> Layers
{
get
{
yield return MainLayer.Value;
yield return WavyLineLayer;
}
}
public override List<Vector4> LayerColors => [Color.White.ToVector4(), EdgeColor.ToVector4()];
public override void Load()
{
if (Main.dedServ)
return;
MainLayer = ModContent.Request<Texture2D>($"CalamityMod/Graphics/Metaballs/ScalArenaLayerSmoke", AssetRequestMode.ImmediateLoad);
WavyLineLayer = ModContent.Request<Texture2D>($"CalamityMod/Graphics/Metaballs/ScalArenaLayerWave", AssetRequestMode.ImmediateLoad).Value;
}
public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeNPCs;
public override Color EdgeColor => ArenaWallSystem.ActiveBoxes.Count > 0 ? ArenaWallSystem.ActiveBoxes[0].borderColor : Color.DarkGray;
public override void Update()
{
for (int i = 0; i < Particles.Count; i++)
Particles[i].Update();
Particles.RemoveAll(p => p.Size <= 2f && p.Age > 1);
}
public static Particle SpawnParticle(Vector2 position, Vector2 velocity, float size)
{
Particle particle = new(position, velocity, size);
Particles.Add(particle);
return particle;
}
public override Vector2 CalculateManualOffsetForLayer(int layerIndex)
{
switch (layerIndex)
{
case 0:
return new Vector2(MathF.Sin(Main.GlobalTimeWrappedHourly*0.03f)*10,MathF.Cos(Main.GlobalTimeWrappedHourly* 0.1f) * 17);
case 1:
return Vector2.UnitY * Main.GlobalTimeWrappedHourly * 0.03f;
}
return Vector2.Zero;
}
bool hasRunTextureCorrection = false;
public override void PrepareSpriteBatch(SpriteBatch spriteBatch)
{
//This only runs once per game session. I put it here as load-related functions use multithreading and therefore don't support drawing functions used here.
//This converts the layer texture into a transparent version, as-if it was additive. Since it's all greyscale, we can just use the red channel from the original in the calculations.
if (!hasRunTextureCorrection)
{
var BaseArray = new Color[WavyLineLayer.Width * WavyLineLayer.Height];
var ColorArray = new Color[WavyLineLayer.Width * WavyLineLayer.Height];
WavyLineLayer.GetData(BaseArray);
for (var i = 0; i < BaseArray.Length; i++)
{
ColorArray[i] = new Color((int)BaseArray[i].R, (int)BaseArray[i].R, (int)BaseArray[i].R, (int)BaseArray[i].R);
}
WavyLineLayer.SetData(ColorArray);
hasRunTextureCorrection = true;
}
base.PrepareSpriteBatch(spriteBatch);
}
public override void DrawInstances()
{
Texture2D tex = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/BasicCircle").Value;
foreach (Particle particle in Particles)
{
var texture2d = particle.TextureToUse ?? tex;
Vector2 drawPosition = particle.Center - Main.screenPosition;
Vector2 scale = particle.Scale * particle.Size / texture2d.Width;
var frame = texture2d.Frame(1, particle.MaxFrames, 0, particle.CurrentFrame);
Vector2 origin = frame.Size() * 0.5f;
Main.spriteBatch.Draw(texture2d, drawPosition, frame, Color.White, particle.rotation, origin, scale, SpriteEffects.None, 0f);
}
}
}
}
+9 -5
View File
@@ -2680,12 +2680,16 @@ namespace CalamityMod.ILEditing
self.Calamity().arenaBoxPosition = new Vector2(Utils.Remap(self.Center.X, box.TopLeft.X, box.BottomRight.X, 0, 1, false), Utils.Remap(self.Center.Y, box.TopLeft.Y, box.BottomRight.Y, 0, 1, false));
self.Calamity().arenaBox = box;
}
self.rotation = self.DirectionFrom(Main.player[self.owner].Center).ToRotation() + MathHelper.PiOver2;
intersectingWall = true;
if (Main.player[self.owner].grapCount < 10)
if (self.ai[0] == 2) //don't run this if the hook is returning!
{
Main.player[self.owner].grappling[Main.player[self.owner].grapCount] = self.whoAmI;
Main.player[self.owner].grapCount++;
self.rotation = self.DirectionFrom(Main.player[self.owner].Center).ToRotation() + MathHelper.PiOver2;
intersectingWall = true;
if (Main.player[self.owner].grapCount < 10)
{
Main.player[self.owner].grappling[Main.player[self.owner].grapCount] = self.whoAmI;
Main.player[self.owner].grapCount++;
}
}
}
}
+1 -1
View File
@@ -130,7 +130,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
// Increase DR if the target leaves SCal's arena.
NPC.Calamity().DR = NormalDR;
if (SCal.ModNPC<SupremeCalamitas>().IsTargetOutsideOfArena)
if (SCal.ModNPC<SupremeCalamitas>().protectionBoost)
NPC.Calamity().DR = SupremeCalamitas.enragedDR;
// Get a target
+63 -30
View File
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using CalamityMod.Dusts;
using CalamityMod.Events;
using CalamityMod.Graphics.Metaballs;
using CalamityMod.Items;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Armor.Vanity;
@@ -185,8 +186,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas
public Vector2 initialRitualPosition;
public Rectangle safeBox = default;
public bool IsTargetOutsideOfArena => !Main.player[NPC.target].Hitbox.Intersects(safeBox);
public static int hoodedHeadIconIndex;
public static int hoodedHeadIconP2Index;
public static int hoodlessHeadIconIndex;
@@ -594,7 +593,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
#endregion
#region ArenaCreation
// Create the arena on the first frame. This does not run client-side.
// Set the variables on the first frame. This does not run client-side.
// If this is done on the server, a sync must be performed so that the arena box is
// known to the clients. Not doing this results in significant desyncs in regards to things like DR.
if (!spawnArena)
@@ -657,6 +656,11 @@ namespace CalamityMod.NPCs.SupremeCalamitas
Color GetArenaColor(out Color oldColor)
{
if (permafrost)
{
oldColor = Color.LightBlue;
return Color.LightBlue;
}
var c = GriefColor;
oldColor = GriefColor;
if (startFifthAttack && gettingTired5 && (giveUpCounter < 1160 || hasDoneDeathAnim))
@@ -672,48 +676,68 @@ namespace CalamityMod.NPCs.SupremeCalamitas
else if (lifeRatio <= 0.5f)
c = LamentColor;
return c;
c = permafrost ? Color.LightBlue : Color.Lerp(Color.Crimson, Color.IndianRed, (MathF.Sin(Main.GlobalTimeWrappedHourly) + 1) * 0.25f);
}
void UpdateArena(ArenaWallSystem.Box box)
{
if (startFifthAttack && gettingTired5 && (giveUpCounter < 1160 || hasDoneDeathAnim))
return;
for (var i2 = 0; i2 < box.Size.Y / 400f; i2++)
{
var p = Vector2.Lerp(box.BottomRight, box.TopRight, Main.rand.NextFloat());
Dust.NewDustPerfect(p, DustID.Clentaminator_Red, p.DirectionFrom(box.Center) * Main.rand.NextFloat(0, 5), Scale: Main.rand.NextFloat(0.1f, 1f), newColor: box.borderColor);
var x = 1f/TextureAssets.MagicPixel.Height();
var p = ScalArenaMetaball.SpawnParticle((box.TopLeft + box.BottomLeft) * 0.5f - new Vector2(box.borderThickness*0.5f + 2,0), Vector2.Zero, 1);
p.SizeScaling = 0;
p.TextureToUse = TextureAssets.MagicPixel.Value;
p.Scale = new Vector2(box.borderThickness-6, box.borderThickness*2 + box.Size.Y-4);
p.Scale.Y *= x;
p = ScalArenaMetaball.SpawnParticle((box.TopRight + box.BottomRight) * 0.5f + new Vector2(box.borderThickness * 0.5f + 2, 0), Vector2.Zero, 1);
p.SizeScaling = 0;
p.TextureToUse = TextureAssets.MagicPixel.Value;
p.Scale = new Vector2(box.borderThickness - 6, box.borderThickness * 2 + box.Size.Y - 4);
p.Scale.Y *= x;
p = Vector2.Lerp(box.TopLeft, box.BottomLeft, Main.rand.NextFloat());
Dust.NewDustPerfect(p, DustID.Clentaminator_Red, p.DirectionFrom(box.Center) * Main.rand.NextFloat(0, 5), Scale: Main.rand.NextFloat(0.1f, 1f), newColor: box.borderColor);
p = ScalArenaMetaball.SpawnParticle((box.TopRight + box.TopLeft) * 0.5f - new Vector2(0,box.borderThickness * 0.5f + 2), Vector2.Zero, 1);
p.SizeScaling = 0;
p.TextureToUse = TextureAssets.MagicPixel.Value;
p.Scale = new Vector2(box.borderThickness * 2 + box.Size.X - 4, box.borderThickness - 6);
p.Scale.Y *= x;
p = ScalArenaMetaball.SpawnParticle((box.BottomLeft + box.BottomRight) * 0.5f + new Vector2(0, box.borderThickness * 0.5f + 2), Vector2.Zero, 1);
p.SizeScaling = 0;
p.TextureToUse = TextureAssets.MagicPixel.Value;
p.Scale = new Vector2(box.borderThickness * 2 + box.Size.X - 4, box.borderThickness - 6);
p.Scale.Y *= x;
for (var i2 = 0; i2 < box.Size.Y / 100f; i2++)
{
var point = Vector2.Lerp(box.BottomRight, box.TopRight, Main.rand.NextFloat());
p = ScalArenaMetaball.SpawnParticle(point + Vector2.UnitX * 8, Vector2.Zero, 16f);
p.SizeScaling = 0.95f;
point = Vector2.Lerp(box.TopLeft, box.BottomLeft, Main.rand.NextFloat());
p = ScalArenaMetaball.SpawnParticle(point + Vector2.UnitX * -8, Vector2.Zero, 16f);
p.SizeScaling = 0.95f;
}
for (var i2 = 0; i2 < box.Size.X / 400f; i2++)
for (var i2 = 0; i2 < box.Size.X / 100f; i2++)
{
var p = Vector2.Lerp(box.TopLeft, box.TopRight, Main.rand.NextFloat());
Dust.NewDustPerfect(p, DustID.Clentaminator_Red, p.DirectionFrom(box.Center) * Main.rand.NextFloat(0, 5), Scale: Main.rand.NextFloat(0.1f, 1f), newColor: box.borderColor);
p = Vector2.Lerp(box.BottomRight, box.BottomLeft, Main.rand.NextFloat());
Dust.NewDustPerfect(p, DustID.Clentaminator_Red, p.DirectionFrom(box.Center) * Main.rand.NextFloat(0, 5), Scale: Main.rand.NextFloat(0.1f, 1f), newColor: box.borderColor);
var point = Vector2.Lerp(box.TopLeft, box.TopRight, Main.rand.NextFloat());
p = ScalArenaMetaball.SpawnParticle(point + Vector2.UnitY * -8, Vector2.Zero, 16f);
p.SizeScaling = 0.95f;
point = Vector2.Lerp(box.BottomRight, box.BottomLeft, Main.rand.NextFloat());
p = ScalArenaMetaball.SpawnParticle(point + Vector2.UnitY * 8, Vector2.Zero, 16f);
p.SizeScaling = 0.95f;
}
}
void DrawArena(ArenaWallSystem.Box box)
{
var color = Color.Black * 0.75f;
var color = Color.Black * 0.15f;
//Inside Fill
box.DrawBoxWithOffset(box.borderThickness * 0.5f, box.borderThickness, Color.Black * 0.75f);
box.DrawBoxWithOffset(box.borderThickness * 0.5f, box.borderThickness, Color.Black * 0.15f);
//Inner Border
box.DrawBoxWithOffset(4, 8, box.borderColor);
//Inner Border Clones
float amount = 4;
float totalDistance = 64f;
for (var i = Main.GlobalTimeWrappedHourly % 1; i < amount; i++)
{
box.DrawBoxWithOffset(totalDistance * (i / amount) + 4, 4, box.borderColor * (1 - i / amount));
}
box.DrawBoxWithOffset(4, 2, box.borderColor * 0.15f);
//Outer Border
box.DrawBoxWithOffset(box.borderThickness - 4, 4, box.borderColor);
box.DrawBoxWithOffset(box.borderThickness - 2, 2, box.borderColor);
}
if (ArenaWallSystem.ActiveBoxes.Count < 1)
@@ -726,6 +750,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas
RemovalCondition = () => !(Main.npc[NPC.whoAmI].active) || Main.npc[NPC.whoAmI].type != Type,
UpdateBox = UpdateArena,
DrawBox = DrawArena,
DespawnAction = (box) =>
{
box.borderThickness *= 0.9f;
if (box.borderThickness < 4)
ArenaWallSystem.ActiveBoxes.Remove(box);
else
UpdateArena(box);
}
}
);
}
@@ -746,18 +778,19 @@ namespace CalamityMod.NPCs.SupremeCalamitas
float projectileVelocityMultCap = 2f;
uDieLul = MathHelper.Clamp(uDieLul * 1.01f, 1f, projectileVelocityMultCap);
protectionBoost = true;
NPC.Calamity().CurrentlyEnraged = true;
}
else
{
uDieLul = MathHelper.Clamp(uDieLul * 0.99f, 1f, 2f);
protectionBoost = false;
NPC.Calamity().CurrentlyEnraged = false;
}
NPC.Calamity().CurrentlyEnraged = !player.Hitbox.Intersects(safeBox);
// Permafrost fucks mounts if you exit his arena.
if (permafrost)
{
if (!player.Hitbox.Intersects(safeBox) && player.mount.Active)
if (NPC.Calamity().CurrentlyEnraged && player.mount.Active)
{
player.ResetEffects();
player.head = -1;
+1 -1
View File
@@ -186,7 +186,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
// Increase DR if the target leaves SCal's arena.
NPC.Calamity().DR = NormalBrothersDR;
if (Main.npc[CalamityGlobalNPC.SCal].ModNPC<SupremeCalamitas>().IsTargetOutsideOfArena)
if (Main.npc[CalamityGlobalNPC.SCal].ModNPC<SupremeCalamitas>().protectionBoost)
NPC.Calamity().DR = SupremeCalamitas.enragedDR;
float totalLifeRatio = NPC.life / (float)NPC.lifeMax;
+1 -1
View File
@@ -181,7 +181,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
// Increase DR if the target leaves SCal's arena.
NPC.Calamity().DR = SupremeCataclysm.NormalBrothersDR;
if (Main.npc[CalamityGlobalNPC.SCal].ModNPC<SupremeCalamitas>().IsTargetOutsideOfArena)
if (Main.npc[CalamityGlobalNPC.SCal].ModNPC<SupremeCalamitas>().protectionBoost)
NPC.Calamity().DR = SupremeCalamitas.enragedDR;
float totalLifeRatio = NPC.life / (float)NPC.lifeMax;