diff --git a/Backgrounds/SunkenSeaBurrowsBG.cs b/Backgrounds/SunkenSeaBurrowsBG.cs
index c7bf587001..4c80584980 100644
--- a/Backgrounds/SunkenSeaBurrowsBG.cs
+++ b/Backgrounds/SunkenSeaBurrowsBG.cs
@@ -1,11 +1,12 @@
-using Terraria;
-using Terraria.ModLoader;
+using CalamityMod.Graphics;
+using CalamityMod.Systems.Graphic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
-using Terraria.ID;
-using CalamityMod.Graphics;
+using Terraria;
using Terraria.Graphics.Shaders;
+using Terraria.ID;
+using Terraria.ModLoader;
namespace CalamityMod.Backgrounds
{
@@ -22,12 +23,17 @@ namespace CalamityMod.Backgrounds
return;
}
- On_Main.CheckMonoliths += DrawToTarget;
+ GeneralDrawLayerSystem.OnPrepareDraw += DrawToTarget;
On_Main.DrawBackgroundBlackFill += On_Main_DrawBackgroundBlackFill;
Main.QueueMainThreadAction(() => WaterDistortionTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget));
}
+ public override void Unload()
+ {
+ GeneralDrawLayerSystem.OnPrepareDraw -= DrawToTarget;
+ }
+
///
/// This code runs because there is a system in vanilla that causes backgrounds to not draw if lighting is too low.
/// That would be fine, the problem arises because sloped tiles still block light the same way normal tiles do.
@@ -119,17 +125,16 @@ namespace CalamityMod.Backgrounds
if (!Main.tile[pos.X, pos.Y].HasTile &&
Main.tile[pos.X, pos.Y].WallType == WallID.None)
Lighting.AddLight(pos.X, pos.Y, TorchID.Red, 0.6f);
- }
+ }
}
}
}
}
- private void DrawToTarget(On_Main.orig_CheckMonoliths orig)
+ private void DrawToTarget()
{
if (Main.gameMenu)
{
- orig();
return;
}
@@ -147,8 +152,6 @@ namespace CalamityMod.Backgrounds
Main.graphics.GraphicsDevice.SetRenderTarget(null);
CurrentlyRendering = false;
-
- orig();
}
private void On_Main_DrawBackgroundBlackFill(On_Main.orig_DrawBackgroundBlackFill orig, Main self)
diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs
index fcbf1c2e22..8258fe08dd 100644
--- a/CalPlayer/CalamityPlayer.cs
+++ b/CalPlayer/CalamityPlayer.cs
@@ -79,6 +79,7 @@ using Terraria.ModLoader.IO;
using Terraria.Net;
using static Terraria.Main;
using static Terraria.ModLoader.ModContent;
+using CalamityMod.NPCs.Ravager;
namespace CalamityMod.CalPlayer
{
@@ -4349,6 +4350,158 @@ namespace CalamityMod.CalPlayer
if (CalamityKeybinds.ExoChairSlowdownHotkey.Current)
Player.velocity *= 0.5f;
}
+
+ foreach (var npc in Main.ActiveNPCs)
+ {
+ //This is the ravager rock pillar collision logic. It should only apply to rock pillars that are mostly opaque to ensure players don't get stopped by invisible pillars right when they spawn.
+ //This could also potentially be limited to only run with the pillar is stationary if desired.
+ if (npc.type == ModContent.NPCType() && npc.Opacity > 0.9f && npc.damage < 1)
+ {
+ bool LandedOnPlayer = false;
+ float origX = Player.velocity.X;
+ float origY = Player.velocity.Y;
+ npc.position += npc.velocity;
+ bool intersectPreVel = false;
+ Player.position += Player.velocity;
+
+ if (Player.Hitbox.Intersects(npc.Hitbox))
+ intersectPreVel = true;
+ Player.position -= Player.velocity;
+ if (intersectPreVel)
+ {
+ Player.position += npc.velocity;
+ if (Collision.SolidCollision(Player.position, Player.Hitbox.Width, Player.Hitbox.Height) || Main.npc.Any(x => x.active && x.type == ModContent.NPCType() && x.Opacity > 0.9f && x.whoAmI != npc.whoAmI && x.Hitbox.Intersects(Player.Hitbox)))
+ {
+ npc.damage = npc.defDamage;
+ npc.ai[0] = 1;
+ LandedOnPlayer = true;
+ Player.position -= npc.velocity;
+ }
+ }
+ npc.position -= npc.velocity;
+
+ if (!LandedOnPlayer)
+ {
+ //Yes, testing intercepts on th X, Y, and X+Y individually has a purpose. It makes it far more stable and consistent.
+ bool intersectX = false;
+ Player.position.X += Player.velocity.X;
+ if (Player.Hitbox.Intersects(npc.Hitbox))
+ intersectX = true;
+ Player.position.X -= Player.velocity.X;
+ bool intersectY = false;
+ Player.position.Y += Player.velocity.Y;
+ if (Player.Hitbox.Intersects(npc.Hitbox))
+ intersectY = true;
+ Player.position.Y -= Player.velocity.Y;
+ bool intersect = false;
+ //We only bother checking the X+Y together if individually they return false.
+ //This accounts for moving diagonal onto a corner.
+ if (!intersectX && !intersectY)
+ {
+ Player.position += Player.velocity;
+ if (Player.Hitbox.Intersects(npc.Hitbox))
+ intersect = true;
+ Player.position -= Player.velocity;
+ }
+ if (intersectX || intersect)
+ {
+ //This checks if the player is to the left of the pillar
+ if (Player.Center.X < npc.Center.X)
+ {
+ float playerEdge = Player.Hitbox.X + Player.Hitbox.Width;
+ float pillarEdge = npc.Hitbox.X;
+ float goalEdge = playerEdge + Player.velocity.X;
+ if (goalEdge > pillarEdge)
+ {
+ Player.velocity.X += pillarEdge - goalEdge;
+ if (Player.velocity.X < 0)
+ if (!Collision.SolidCollision(Player.position + new Vector2(Player.velocity.X, 0), Player.Hitbox.Width, Player.Hitbox.Height))
+ {
+ Player.position.X += Player.velocity.X;
+ Player.velocity.X = 0;
+ }
+ else
+ {
+ Player.velocity.X = origX;
+ }
+ }
+ }
+ //This is for if the player is to the right of the pillar
+ else
+ {
+ float playerEdge = Player.Hitbox.X;
+ float pillarEdge = npc.Hitbox.X + npc.Hitbox.Width;
+ float goalEdge = playerEdge + Player.velocity.X;
+ if (goalEdge < pillarEdge)
+ {
+ Player.velocity.X += pillarEdge - goalEdge;
+ if (Player.velocity.X > 0)
+ if (!Collision.SolidCollision(Player.position + new Vector2(Player.velocity.X, 0), Player.Hitbox.Width, Player.Hitbox.Height))
+ {
+ Player.position.X += Player.velocity.X;
+ Player.velocity.X = 0;
+ }
+ else
+ {
+ Player.velocity.X = origX;
+ }
+ }
+ }
+ }
+ //For the vertical axis, we don't distinguish between top and bottom, and always move players to the top
+ //This is so being placed inside a pillar teleports a player to the top, which applies primarily to teleporting or pillar spawning
+ //Additionally, this is set to only work when the pillar is stationary vertically to prevent janky interations when pillars are moving.
+ if ((intersectY || intersect))
+ {
+ if (Player.Center.Y < npc.Center.Y)
+ {
+ float playerEdge = Player.Hitbox.Y + Player.Hitbox.Height;
+ float pillarEdge = npc.Hitbox.Y;
+ float goalEdge = playerEdge + Player.velocity.Y;
+ if (goalEdge > pillarEdge)
+ {
+ Player.velocity.Y += pillarEdge - goalEdge;
+ if (Player.velocity.Y < 0)
+ if (!Collision.SolidCollision(Player.position + new Vector2(0, Player.velocity.Y), Player.Hitbox.Width, Player.Hitbox.Height))
+ {
+ Player.position.Y += Player.velocity.Y;
+ Player.velocity.Y = 0;
+ }
+ else
+ {
+ Player.velocity.Y = origY;
+ }
+ }
+ }
+ else
+ {
+ float playerEdge = Player.Hitbox.Y;
+ float pillarEdge = npc.Hitbox.Y + npc.Hitbox.Height;
+ float goalEdge = playerEdge + Player.velocity.Y;
+ if (goalEdge < pillarEdge)
+ {
+ Player.velocity.Y += pillarEdge - goalEdge;
+ if (Player.velocity.Y > 0)
+ if (!Collision.SolidCollision(Player.position + new Vector2(0, Player.velocity.Y), Player.Hitbox.Width, Player.Hitbox.Height))
+ {
+ Player.position.Y += Player.velocity.Y;
+ Player.velocity.Y = 0;
+ }
+ else
+ {
+ Player.velocity.Y = origY;
+ }
+ }
+ }
+ }
+ //This is to guarantee we can stand on top of rock pillars instead of looking like we're "floating" on top of them.
+ if (intersectY && Player.velocity.Y < 0.25f && Player.velocity.Y > -0.25f)
+ {
+ Player.velocity.Y = 0;
+ }
+ }
+ }
+ }
}
#endregion
diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs
index 5fa9b6fcaa..401839b99e 100644
--- a/CalPlayer/CalamityPlayerHitHurt.cs
+++ b/CalPlayer/CalamityPlayerHitHurt.cs
@@ -874,6 +874,22 @@ namespace CalamityMod.CalPlayer
#region Modify Hit By Proj
public override void ModifyHitByProjectile(Projectile proj, ref Player.HurtModifiers modifiers)
{
+ //This goes first so it activated before dodges or any other effects, as these projectiles aren't supposed to "hit" the player, but just inflict debuffs
+ if (CalamityWorld.revenge)
+ {
+ if (proj.type == ProjectileID.CultistBossIceMist && proj.ai[1] == 1f) // Main ice mists only; no shards
+ {
+ Player.AddBuff(BuffID.Frozen, 120);
+ modifiers.Cancel();
+ return;
+ }
+ else if (proj.type == ProjectileID.CultistBossIceMist && proj.ai[1] != 1f) // Ice Mist shards
+ {
+ Player.AddBuff(BuffID.Chilled, 240);
+ modifiers.Cancel();
+ return;
+ }
+ }
if (!CalamityProjectileSets.ShouldNotBeReflected[proj.type] && proj.active && !proj.friendly && proj.hostile && proj.damage > 0 && !modifiers.PvP)
{
double dodgeDamageGateValuePercent = 0.05;
@@ -1324,10 +1340,6 @@ namespace CalamityMod.CalPlayer
{
Player.AddBuff(ModContent.BuffType(), 180);
}
- else if (proj.type == ProjectileID.CultistBossIceMist && proj.ai[1] == 1f) // Main ice mists only; no shards
- {
- Player.AddBuff(BuffID.Chilled, 180);
- }
else if (proj.type == ProjectileID.CultistBossLightningOrbArc)
{
Player.AddBuff(BuffID.Electrified, 180);
diff --git a/CalamityNetcode.cs b/CalamityNetcode.cs
index ec95e43bc7..bfffa1013f 100644
--- a/CalamityNetcode.cs
+++ b/CalamityNetcode.cs
@@ -145,7 +145,6 @@ namespace CalamityMod
ExaltationDirection,
// Syncs for specific bosses or entities
- SyncDestroyerLaserColor,
SyncCalamityNPCAIArray,
SyncVanillaNPCLocalAIArray,
SpawnSuperDummy,
diff --git a/Graphics/Metaballs/MetaballManager.cs b/Graphics/Metaballs/MetaballManager.cs
index 123e007766..aa1bf3ab10 100644
--- a/Graphics/Metaballs/MetaballManager.cs
+++ b/Graphics/Metaballs/MetaballManager.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Enums;
+using CalamityMod.Systems.Graphic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -12,9 +13,10 @@ namespace CalamityMod.Graphics.Metaballs
{
internal static readonly List metaballs = new();
- public override void OnModLoad()
+ public override void Load()
{
// Prepare event subscribers.
+ GeneralDrawLayerSystem.OnDrawLayer += DrawMetaballs;
RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareMetaballTargets;
}
@@ -96,8 +98,10 @@ namespace CalamityMod.Graphics.Metaballs
/// Draws all metaballs of a given . Used for layer ordering reasons.
///
/// The layer type to draw with.
- internal static void DrawMetaballs(GeneralDrawLayer layerType)
+ private static void DrawMetaballs(GeneralDrawLayer layerType)
{
+ Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
+
foreach (Metaball metaball in metaballs.Where(m => m.DrawLayer == layerType && m.AnythingToDraw))
{
for (int i = 0; i < metaball.LayerTargets.Count; i++)
@@ -109,6 +113,8 @@ namespace CalamityMod.Graphics.Metaballs
Main.spriteBatch.Draw(metaball.LayerTargets[i], Main.screenLastPosition - Main.screenPosition, Color.White);
}
}
+
+ Main.spriteBatch.End();
}
}
}
diff --git a/Graphics/Primitives/PrimitivePixelationSystem.cs b/Graphics/Primitives/PrimitivePixelationSystem.cs
index 36a0e186b8..3fa1d49fbc 100644
--- a/Graphics/Primitives/PrimitivePixelationSystem.cs
+++ b/Graphics/Primitives/PrimitivePixelationSystem.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Enums;
+using CalamityMod.Systems.Graphic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -60,7 +61,8 @@ namespace CalamityMod.Graphics.Primitives
PixelationTarget_AfterEverything = new(true, CreatePixelTarget);
});
- On_Main.CheckMonoliths += DrawToTargets;
+ GeneralDrawLayerSystem.OnDrawLayer += DrawTargetScaled;
+ GeneralDrawLayerSystem.OnPrepareDraw += DrawToTargets;
//On_Main.DrawBackgroundBlackFill += DrawTarget_BeforeAllTiles;
//On_Main.DoDraw_Tiles_Solid += DrawTarget_BeforeSolidTiles;
//On_Main.DoDraw_DrawNPCsOverTiles += DrawTarget_NPCs;
@@ -75,16 +77,16 @@ namespace CalamityMod.Graphics.Primitives
if (Main.dedServ)
return;
- On_Main.CheckMonoliths -= DrawToTargets;
+ GeneralDrawLayerSystem.OnDrawLayer -= DrawTargetScaled;
+ GeneralDrawLayerSystem.OnPrepareDraw -= DrawToTargets;
}
#endregion
#region Drawing To Targets
- private void DrawToTargets(On_Main.orig_CheckMonoliths orig)
+ private void DrawToTargets()
{
if (Main.gameMenu)
{
- orig();
return;
}
@@ -167,7 +169,6 @@ namespace CalamityMod.Graphics.Primitives
Main.instance.GraphicsDevice.SetRenderTarget(null);
CurrentlyRendering = false;
- orig();
}
private static void DrawPrimsToRenderTarget(RenderTarget2D renderTarget, GeneralDrawLayer layer, List pixelPrimitives)
@@ -188,15 +189,11 @@ namespace CalamityMod.Graphics.Primitives
#endregion
#region Target Drawing
- internal static void DrawTargetScaled(GeneralDrawLayer drawLayer, bool startSpritebatch = true)
+ private static void DrawTargetScaled(GeneralDrawLayer drawLayer)
{
- if (startSpritebatch)
- Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
-
+ Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
Main.spriteBatch.Draw(ReturnAssociatedRenderTarget(drawLayer), Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f);
-
- if (startSpritebatch)
- Main.spriteBatch.End();
+ Main.spriteBatch.End();
}
private static RenderTarget2D ReturnAssociatedRenderTarget(GeneralDrawLayer drawLayer)
diff --git a/Graphics/Primitives/PrimitiveRenderer.cs b/Graphics/Primitives/PrimitiveRenderer.cs
index 6e316969bb..4f06690c39 100644
--- a/Graphics/Primitives/PrimitiveRenderer.cs
+++ b/Graphics/Primitives/PrimitiveRenderer.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -30,20 +29,46 @@ namespace CalamityMod.Graphics.Primitives
private static PrimitiveSettings MainSettings;
+ private static PrimitiveTopology ActiveTopology;
+
private static Vector2[] MainPositions;
+ private static Vector2[] MainTangents;
+
+ private static Vector2[] MainNormals;
+
private static VertexPosition2DColorTexture[] MainVertices;
private static short[] MainIndices;
+ private static VertexPositionColor[] WireframeVertices;
+
+ private static int WireframeVertexCount;
+
+ private static BasicEffect WireframeEffect;
+
+ private static int[] NonSmoothIndexScratch;
+
+ private static short StartCapCenterIndex;
+
+ private static short EndCapCenterIndex;
+
private const short MaxPositions = 1000;
private const short MaxVertices = 3072;
private const short MaxIndices = 8192;
+ private static readonly List ControlPointsCache = new(MaxPositions);
+
private static short PositionsIndex;
+ private static float[] MainCompletionRatios;
+
+ private static float TotalTrailLength;
+
+ public const float Epsilon = 1e-6f;
+
private static short VerticesIndex;
private static short IndicesIndex;
@@ -55,11 +80,28 @@ namespace CalamityMod.Graphics.Primitives
MainPositions = new Vector2[MaxPositions];
MainVertices = new VertexPosition2DColorTexture[MaxVertices];
MainIndices = new short[MaxIndices];
+ MainCompletionRatios = new float[MaxPositions];
+ MainTangents = new Vector2[MaxPositions];
+ MainNormals = new Vector2[MaxPositions];
+ WireframeVertices = new VertexPositionColor[MaxPositions * 8];
+ NonSmoothIndexScratch = new int[MaxPositions];
VertexBuffer ??= new DynamicVertexBuffer(Main.instance.GraphicsDevice, VertexPosition2DColorTexture.VertexDeclaration2D, MaxVertices, BufferUsage.WriteOnly);
IndexBuffer ??= new DynamicIndexBuffer(Main.instance.GraphicsDevice, IndexElementSize.SixteenBits, MaxIndices, BufferUsage.WriteOnly);
+ WireframeEffect ??= new BasicEffect(Main.instance.GraphicsDevice)
+ {
+ VertexColorEnabled = true,
+ TextureEnabled = false,
+ LightingEnabled = false
+ };
});
}
+ public override void OnModUnload()
+ {
+ WireframeEffect?.Dispose();
+ WireframeEffect = null;
+ }
+
private static void PerformPixelationSafetyChecks(PrimitiveSettings settings)
{
// Don't allow accidental screw ups with these.
@@ -92,21 +134,27 @@ namespace CalamityMod.Graphics.Primitives
return;
// Return if too many to draw anything,
- if (positions.Length >= MaxPositions)
+ if (positions.Length > MaxPositions)
return;
+ int desiredPointCount = pointsToCreate ?? positions.Length;
+ desiredPointCount = Math.Clamp(desiredPointCount, 2, MaxPositions);
+
+ MainSettings = settings;
+ ActiveTopology = settings.CapStyle != PrimitiveCapStyle.None ? PrimitiveTopology.TriangleList : settings.Topology;
+
// IF this is false, a correct position trail could not be made and rendering should not continue.
- if (!AssignPointsRectangleTrail(positions, settings, pointsToCreate ?? positions.Length))
+ if (!AssignPointsRectangleTrail(positions, settings, desiredPointCount))
return;
// A trail with only one point or less has nothing to connect to, and therefore, can't make a trail.
- if (MainPositions.Length <= 2)
+ AssignCompletionData();
+
+ if (PositionsIndex <= 2)
return;
- MainSettings = settings;
-
AssignVerticesRectangleTrail();
- AssignIndicesRectangleTrail();
+ AssignIndices();
// Else render without wasting resources creating a set.
PrivateRender();
@@ -115,7 +163,15 @@ namespace CalamityMod.Graphics.Primitives
private static void PrivateRender()
{
- if (IndicesIndex % 6 != 0 || VerticesIndex <= 3)
+ if (VerticesIndex <= 3)
+ return;
+
+ if (ActiveTopology == PrimitiveTopology.TriangleList)
+ {
+ if (IndicesIndex < 6 || IndicesIndex % 3 != 0)
+ return;
+ }
+ else if (ActiveTopology == PrimitiveTopology.TriangleStrip && IndicesIndex < 4)
return;
// Perform screen culling, for performance reasons.
@@ -139,7 +195,13 @@ namespace CalamityMod.Graphics.Primitives
Main.instance.GraphicsDevice.SetVertexBuffer(VertexBuffer);
Main.instance.GraphicsDevice.Indices = IndexBuffer;
- Main.instance.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, VerticesIndex, 0, IndicesIndex / 3);
+
+ PrimitiveType primitiveType = ActiveTopology == PrimitiveTopology.TriangleStrip ? PrimitiveType.TriangleStrip : PrimitiveType.TriangleList;
+ int primitiveCount = primitiveType == PrimitiveType.TriangleStrip ? Math.Max(IndicesIndex - 2, 0) : IndicesIndex / 3;
+ Main.instance.GraphicsDevice.DrawIndexedPrimitives(primitiveType, 0, 0, VerticesIndex, 0, primitiveCount);
+
+ if (MainSettings.DebugWireframe && WireframeEffect != null && TryBuildWireframeGeometry(MainSettings.WireframeColor, out int lineCount))
+ DrawWireframe(view, projection, lineCount);
}
#endregion
@@ -151,40 +213,50 @@ namespace CalamityMod.Graphics.Primitives
{
PositionsIndex = 0;
- // Would like to remove this, but unsure how else to properly ensure that none are zero.
- positions = positions.Where(originalPosition => originalPosition != Vector2.Zero).ToArray();
+ int validCount = 0;
+ for (int i = 0; i < positions.Length; i++)
+ {
+ if (positions[i] == Vector2.Zero)
+ continue;
- if (positions.Length <= 2)
+ NonSmoothIndexScratch[validCount++] = i;
+ }
+
+ if (validCount <= 2)
return false;
- // Remap the original positions across a certain length.
+ int lastIndex = validCount - 1;
+ float inversePointCount = 1f / (pointsToCreate - 1);
+ float lastIndexFloat = lastIndex;
+
+ // Remap the original positions across a certain length without additional allocations.
for (int i = 0; i < pointsToCreate; i++)
{
- float completionRatio = i / (float)(pointsToCreate - 1f);
- int currentIndex = (int)(completionRatio * (positions.Length - 1));
- Vector2 currentPoint = positions[currentIndex];
- Vector2 nextPoint = positions[(currentIndex + 1) % positions.Length];
+ float completionRatio = i * inversePointCount;
+ float scaledIndex = completionRatio * lastIndexFloat;
+ int currentIndex = (int)scaledIndex;
+ int nextIndex = Math.Min(currentIndex + 1, lastIndex);
+ float localInterpolant = scaledIndex - currentIndex;
- // 29FEB2024: Ozzatron: offset function needs to apply even in cases where smoothing is off.
- Vector2 finalPos = Vector2.Lerp(currentPoint, nextPoint, completionRatio * (positions.Length - 1) % 0.99999f) - Main.screenPosition;
+ Vector2 currentPoint = positions[NonSmoothIndexScratch[currentIndex]];
+ Vector2 nextPoint = positions[NonSmoothIndexScratch[nextIndex]];
+ Vector2 interpolatedWorld = Vector2.Lerp(currentPoint, nextPoint, localInterpolant);
+ Vector2 finalPos = interpolatedWorld - Main.screenPosition;
if (settings.OffsetFunction != null)
- finalPos += settings.OffsetFunction(completionRatio, finalPos);
+ finalPos += settings.OffsetFunction(completionRatio, interpolatedWorld);
- MainPositions[PositionsIndex] = finalPos;
- PositionsIndex++;
+ MainPositions[PositionsIndex++] = finalPos;
}
return true;
}
- // Due to the first point being manually added, points should be added starting at the second position instead of the first.
- PositionsIndex = 1;
+ PositionsIndex = 0;
// Create the control points for the spline.
- List controlPoints = new();
+ List controlPoints = ControlPointsCache;
+ controlPoints.Clear();
for (int i = 0; i < positions.Length; i++)
{
- // Don't incorporate points that are zeroed out.
- // They are almost certainly a result of incomplete oldPos arrays.
if (positions[i] == Vector2.Zero)
continue;
@@ -195,97 +267,545 @@ namespace CalamityMod.Graphics.Primitives
controlPoints.Add(positions[i] + offset);
}
- // Avoid stupid index errors.
- if (controlPoints.Count <= 4)
+ int controlCount = controlPoints.Count;
+ if (controlCount <= 1)
+ {
+ controlPoints.Clear();
return false;
+ }
+
+ int segmentCount = controlCount - 1;
+
+ if (settings.SmoothingSegments > 0)
+ {
+ int segmentsPerEdge = Math.Max(1, settings.SmoothingSegments);
+ PrimitiveSmoothingType smoothingType = settings.SmoothingType;
+
+ for (int segment = 0; segment < segmentCount; segment++)
+ {
+ Vector2 p0 = controlPoints[Math.Max(segment - 1, 0)];
+ Vector2 p1 = controlPoints[segment];
+ Vector2 p2 = controlPoints[segment + 1];
+ Vector2 p3 = controlPoints[Math.Min(segment + 2, controlCount - 1)];
+
+ for (int step = segment == 0 ? 0 : 1; step <= segmentsPerEdge; step++)
+ {
+ if (PositionsIndex >= MaxPositions - 1)
+ {
+ controlPoints.Clear();
+ return true;
+ }
+
+ float localT = step / (float)segmentsPerEdge;
+ Vector2 point = EvaluateCurve(smoothingType, p0, p1, p2, p3, localT, settings);
+ MainPositions[PositionsIndex++] = point;
+ }
+ }
+
+ controlPoints.Clear();
+ return true;
+ }
+
+ // Legacy behaviour: sample based on requested point count using Catmull-Rom style interpolation.
+ PositionsIndex = 1;
+ float controlCountMinusOne = controlCount - 1f;
+ PrimitiveSmoothingType legacyType = settings.SmoothingType;
for (int j = 0; j < pointsToCreate; j++)
{
+ if (PositionsIndex >= MaxPositions - 1)
+ break;
+
float splineInterpolant = j / (float)pointsToCreate;
- float localSplineInterpolant = splineInterpolant * (controlPoints.Count - 1f) % 1f;
- int localSplineIndex = (int)(splineInterpolant * (controlPoints.Count - 1f));
+ float positionOnCurve = splineInterpolant * controlCountMinusOne;
+ int localSplineIndex = (int)positionOnCurve;
+ float localSplineInterpolant = positionOnCurve - localSplineIndex;
- Vector2 farLeft;
- Vector2 left = controlPoints[localSplineIndex];
- Vector2 right = controlPoints[localSplineIndex + 1];
- Vector2 farRight;
+ Vector2 p0 = controlPoints[Math.Max(localSplineIndex - 1, 0)];
+ Vector2 p1 = controlPoints[localSplineIndex];
+ Vector2 p2 = controlPoints[Math.Min(localSplineIndex + 1, controlCount - 1)];
+ Vector2 p3 = controlPoints[Math.Min(localSplineIndex + 2, controlCount - 1)];
- // Special case: If the spline attempts to access the previous/next index but the index is already at the very beginning/end, simply
- // cheat a little bit by creating a phantom point that's mirrored from the previous one.
- if (localSplineIndex <= 0)
- {
- Vector2 mirrored = left * 2f - right;
- farLeft = mirrored;
- }
- else
- farLeft = controlPoints[localSplineIndex - 1];
-
- if (localSplineIndex >= controlPoints.Count - 2)
- {
- Vector2 mirrored = right * 2f - left;
- farRight = mirrored;
- }
- else
- farRight = controlPoints[localSplineIndex + 2];
-
- MainPositions[PositionsIndex] = Vector2.CatmullRom(farLeft, left, right, farRight, localSplineInterpolant);
+ MainPositions[PositionsIndex] = EvaluateCurve(legacyType, p0, p1, p2, p3, localSplineInterpolant, settings);
PositionsIndex++;
}
- // Manually insert the front and end points.
- MainPositions[0] = controlPoints.First();
- MainPositions[PositionsIndex] = controlPoints.Last();
+ MainPositions[0] = controlPoints[0];
+ MainPositions[PositionsIndex] = controlPoints[controlCount - 1];
PositionsIndex++;
+ controlPoints.Clear();
return true;
}
+ private static void AssignCompletionData()
+ {
+ TotalTrailLength = 0f;
+
+ if (PositionsIndex <= 0)
+ return;
+
+ MainCompletionRatios[0] = 0f;
+
+ for (int i = 1; i < PositionsIndex; i++)
+ {
+ float segmentLength = Vector2.Distance(MainPositions[i], MainPositions[i - 1]);
+ TotalTrailLength += segmentLength;
+ MainCompletionRatios[i] = TotalTrailLength;
+ }
+
+ if (PositionsIndex <= 0)
+ return;
+
+ if (TotalTrailLength > Epsilon)
+ {
+ float inverseTotal = 1f / TotalTrailLength;
+ int lastIndex = PositionsIndex - 1;
+
+ if (System.Numerics.Vector.IsHardwareAccelerated && PositionsIndex - 1 >= System.Numerics.Vector.Count)
+ {
+ var scale = new System.Numerics.Vector(inverseTotal);
+ int i = 1;
+ int upperBound = lastIndex - System.Numerics.Vector.Count + 1;
+ for (; i <= upperBound; i += System.Numerics.Vector.Count)
+ {
+ var values = new System.Numerics.Vector(MainCompletionRatios, i);
+ (values * scale).CopyTo(MainCompletionRatios, i);
+ }
+
+ for (; i <= lastIndex; i++)
+ MainCompletionRatios[i] *= inverseTotal;
+ }
+ else
+ {
+ for (int i = 1; i < PositionsIndex; i++)
+ MainCompletionRatios[i] *= inverseTotal;
+ }
+
+ MainCompletionRatios[PositionsIndex - 1] = 1f;
+ }
+ else
+ {
+ for (int i = 1; i < PositionsIndex; i++)
+ MainCompletionRatios[i] = 0f;
+ }
+ }
+
private static void AssignVerticesRectangleTrail()
{
VerticesIndex = 0;
+ StartCapCenterIndex = -1;
+ EndCapCenterIndex = -1;
+ ComputeFrameData();
for (int i = 0; i < PositionsIndex; i++)
{
- float completionRatio = (i - 1f) / (float)(PositionsIndex - 1);
- Vector2 currentPosition = MainPositions[i];
- float widthAtVertex = MainSettings.WidthFunction(completionRatio,currentPosition);
- Color vertexColor = MainSettings.ColorFunction(completionRatio, currentPosition);
+ float completionRatio = GetCompletionRatioForIndex(i);
+ float widthAtVertex = Math.Max(MainSettings.WidthFunction(completionRatio, MainPositions[i]), 0f);
+ Color vertexColor = MainSettings.ColorFunction(completionRatio, MainPositions[i]);
+ float textureU = ComputeTextureCoordinateForIndex(i, completionRatio);
- Vector2 directionToAhead = i == PositionsIndex - 1 ? (MainPositions[i] - MainPositions[i - 1]).SafeNormalize(Vector2.Zero) : (MainPositions[i + 1] - MainPositions[i]).SafeNormalize(Vector2.Zero);
- Vector2 leftCurrentTextureCoord = new(completionRatio, 0.5f - widthAtVertex * 0.5f);
- Vector2 rightCurrentTextureCoord = new(completionRatio, 0.5f + widthAtVertex * 0.5f);
-
- // Point 90 degrees away from the direction towards the next point, and use it to mark the edges of the rectangle.
- // This doesn't use RotatedBy for the sake of performance (there can potentially be a lot of trail points).
- Vector2 sideDirection = new(-directionToAhead.Y, directionToAhead.X);
-
- Vector2 left = currentPosition - sideDirection * widthAtVertex;
- Vector2 right = currentPosition + sideDirection * widthAtVertex;
+ ComputeEdgePositions(i, widthAtVertex, out Vector2 left, out Vector2 right, out float effectiveHalfWidth);
// Override the initial vertex positions if requested.
if (i == 0 && MainSettings.InitialVertexPositionsOverride.HasValue && MainSettings.InitialVertexPositionsOverride.Value.Item1 != Vector2.Zero && MainSettings.InitialVertexPositionsOverride.Value.Item2 != Vector2.Zero)
{
left = MainSettings.InitialVertexPositionsOverride.Value.Item1;
right = MainSettings.InitialVertexPositionsOverride.Value.Item2;
+ effectiveHalfWidth = Math.Max(Vector2.Distance(left, right) * 0.5f, Epsilon);
}
- // What this is doing, at its core, is defining a rectangle based on two triangles.
- // These triangles are defined based on the width of the strip at that point.
- // The resulting rectangles combined are what make the trail itself.
- MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(left, vertexColor, leftCurrentTextureCoord, widthAtVertex);
+ // Guard against degenerate width
+ effectiveHalfWidth = Math.Max(effectiveHalfWidth, Epsilon);
+
+ Vector2 leftCurrentTextureCoord = new Vector2(textureU, 0.5f - effectiveHalfWidth * 0.5f);
+ Vector2 rightCurrentTextureCoord = new Vector2(textureU, 0.5f + effectiveHalfWidth * 0.5f);
+
+ MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(left, vertexColor, leftCurrentTextureCoord, effectiveHalfWidth);
VerticesIndex++;
- MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(right, vertexColor, rightCurrentTextureCoord, widthAtVertex);
+ MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(right, vertexColor, rightCurrentTextureCoord, effectiveHalfWidth);
VerticesIndex++;
}
+
+ AddCaps();
+ }
+
+ private static void AddCaps()
+ {
+ if (MainSettings.CapStyle == PrimitiveCapStyle.None || PositionsIndex <= 0)
+ return;
+
+ if (ActiveTopology == PrimitiveTopology.TriangleStrip)
+ return;
+
+ StartCapCenterIndex = TryCreateCapVertex(0);
+ if (PositionsIndex > 1)
+ EndCapCenterIndex = TryCreateCapVertex(PositionsIndex - 1);
+ }
+
+ private static short TryCreateCapVertex(int positionIndex)
+ {
+ if (VerticesIndex >= MaxVertices - 1)
+ return -1;
+
+ int leftVertexIndex = positionIndex * 2;
+ int rightVertexIndex = leftVertexIndex + 1;
+ if (rightVertexIndex >= VerticesIndex)
+ return -1;
+
+ ref readonly VertexPosition2DColorTexture leftVertex = ref MainVertices[leftVertexIndex];
+ ref readonly VertexPosition2DColorTexture rightVertex = ref MainVertices[rightVertexIndex];
+
+ Vector2 centerPosition = MainPositions[positionIndex];
+ Color centerColor = Color.Lerp(leftVertex.Color, rightVertex.Color, 0.5f);
+ float centerHalfWidth = Math.Max(Math.Max(leftVertex.TextureCoordinates.Z, rightVertex.TextureCoordinates.Z), Epsilon);
+ float centerU = (leftVertex.TextureCoordinates.X + rightVertex.TextureCoordinates.X) * 0.5f;
+ Vector2 centerTexcoord = new(centerU, 0.5f);
+
+ short newVertexIndex = VerticesIndex;
+ MainVertices[VerticesIndex++] = new VertexPosition2DColorTexture(centerPosition, centerColor, centerTexcoord, centerHalfWidth);
+ return newVertexIndex;
+ }
+
+ private static float GetCompletionRatioForIndex(int index)
+ {
+ if (PositionsIndex <= 0)
+ return 0f;
+
+ if (index <= 0)
+ return MainCompletionRatios[0];
+
+ if (index >= PositionsIndex)
+ return MainCompletionRatios[PositionsIndex - 1];
+
+ return MainCompletionRatios[index];
+ }
+
+ private static float ComputeTextureCoordinateForIndex(int index, float completionRatio)
+ {
+ float clampedCompletion = MathHelper.Clamp(completionRatio, 0f, 1f);
+
+ if (MainSettings.TextureCoordinateFunction != null)
+ return MainSettings.TextureCoordinateFunction(clampedCompletion);
+
+ float cycleLength = MainSettings.TextureCycleLength;
+ if (Math.Abs(cycleLength) <= Epsilon)
+ cycleLength = cycleLength >= 0f ? 1f : -1f;
+
+ switch (MainSettings.TextureCoordinateMode)
+ {
+ case PrimitiveTextureMode.Distance:
+ float distance = clampedCompletion * TotalTrailLength + MainSettings.TextureScrollOffset;
+ return distance / cycleLength;
+
+ default:
+ return clampedCompletion * cycleLength + MainSettings.TextureScrollOffset;
+ }
}
- private static void AssignIndicesRectangleTrail()
+ private static void ComputeFrameData()
{
+ if (PositionsIndex <= 0)
+ return;
+
+ Vector2 fallbackTangent = Vector2.UnitX;
+
+ for (int i = 0; i < PositionsIndex; i++)
+ {
+ Vector2 tangent = ComputeTangent(i, fallbackTangent);
+ tangent = tangent.SafeNormalize(fallbackTangent.SafeNormalize(Vector2.UnitX));
+ MainTangents[i] = tangent;
+ fallbackTangent = tangent;
+ }
+
+ Vector2 previousNormal = Vector2.Zero;
+
+ for (int i = 0; i < PositionsIndex; i++)
+ {
+ Vector2 tangent = MainTangents[i];
+ if (tangent.LengthSquared() <= Epsilon)
+ tangent = fallbackTangent.SafeNormalize(Vector2.UnitX);
+
+ Vector2 baseNormal = new Vector2(-tangent.Y, tangent.X);
+ Vector2 normal;
+
+ if (MainSettings.FrameTransportMode == PrimitiveFrameTransportMode.ParallelTransport && i > 0 && previousNormal.LengthSquared() > Epsilon)
+ {
+ Vector2 previousTangent = MainTangents[i - 1];
+ float cosine = MathHelper.Clamp(Vector2.Dot(previousTangent, tangent), -1f, 1f);
+ float sine = Cross(previousTangent, tangent);
+ Vector2 transported = new Vector2(
+ cosine * previousNormal.X - sine * previousNormal.Y,
+ sine * previousNormal.X + cosine * previousNormal.Y
+ );
+ normal = transported;
+ }
+ else
+ normal = baseNormal;
+
+ if (normal.LengthSquared() <= Epsilon)
+ normal = previousNormal.LengthSquared() > Epsilon ? previousNormal : baseNormal;
+
+ normal = normal.SafeNormalize(previousNormal.LengthSquared() > Epsilon ? previousNormal : Vector2.UnitY);
+ MainNormals[i] = normal;
+ previousNormal = normal;
+ }
+ }
+
+ private static Vector2 ComputeTangent(int index, Vector2 fallback)
+ {
+ int last = PositionsIndex - 1;
+ Vector2 tangent;
+
+ if (PositionsIndex <= 1)
+ {
+ tangent = fallback;
+ }
+ else if (index <= 0)
+ {
+ tangent = MainPositions[1] - MainPositions[0];
+ }
+ else if (index >= last)
+ {
+ tangent = MainPositions[last] - MainPositions[last - 1];
+ }
+ else
+ {
+ Vector2 forward = MainPositions[index + 1] - MainPositions[index];
+ Vector2 backward = MainPositions[index] - MainPositions[index - 1];
+ tangent = forward + backward;
+
+ if (tangent.LengthSquared() <= Epsilon)
+ tangent = forward.LengthSquared() >= backward.LengthSquared() ? forward : backward;
+ }
+
+ if (tangent.LengthSquared() <= Epsilon)
+ tangent = fallback.LengthSquared() > Epsilon ? fallback : Vector2.UnitX;
+
+ return tangent;
+ }
+
+ private static Vector2 EvaluateCurve(PrimitiveSmoothingType type, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, float t, PrimitiveSettings settings)
+ {
+ t = MathHelper.Clamp(t, 0f, 1f);
+
+ switch (type)
+ {
+ case PrimitiveSmoothingType.Linear:
+ return Vector2.Lerp(p1, p2, t);
+
+ case PrimitiveSmoothingType.Cardinal:
+ {
+ float tension = MathHelper.Clamp(settings.SmoothingTension, -1f, 1f);
+ float scale = (1f - tension) * 0.5f;
+ Vector2 m0 = (p2 - p0) * scale;
+ Vector2 m1 = (p3 - p1) * scale;
+ return EvaluateHermiteSpan(p1, p2, m0, m1, t);
+ }
+
+ case PrimitiveSmoothingType.Hermite:
+ {
+ Vector2 m0 = 0.5f * (p2 - p0);
+ Vector2 m1 = 0.5f * (p3 - p1);
+ return EvaluateHermiteSpan(p1, p2, m0, m1, t);
+ }
+
+ case PrimitiveSmoothingType.CubicBezier:
+ {
+ Vector2 handle1 = p1 + (p2 - p0) / 3f;
+ Vector2 handle2 = p2 - (p3 - p1) / 3f;
+ return EvaluateBezierSpan(p1, handle1, handle2, p2, t);
+ }
+
+ default:
+ return Vector2.CatmullRom(p0, p1, p2, p3, t);
+ }
+ }
+
+ private static Vector2 EvaluateHermiteSpan(Vector2 start, Vector2 end, Vector2 tangentStart, Vector2 tangentEnd, float t)
+ {
+ float t2 = t * t;
+ float t3 = t2 * t;
+ float h00 = 2f * t3 - 3f * t2 + 1f;
+ float h10 = t3 - 2f * t2 + t;
+ float h01 = -2f * t3 + 3f * t2;
+ float h11 = t3 - t2;
+ return h00 * start + h10 * tangentStart + h01 * end + h11 * tangentEnd;
+ }
+
+ private static Vector2 EvaluateBezierSpan(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, float t)
+ {
+ float u = 1f - t;
+ float u2 = u * u;
+ float u3 = u2 * u;
+ float t2 = t * t;
+ float t3 = t2 * t;
+ return u3 * p0 + 3f * u2 * t * p1 + 3f * u * t2 * p2 + t3 * p3;
+ }
+
+ private static void ComputeEdgePositions(int index, float halfWidth, out Vector2 left, out Vector2 right, out float effectiveHalfWidth)
+ {
+ Vector2 currentPosition = MainPositions[index];
+
+ if (halfWidth <= 0f)
+ {
+ left = currentPosition;
+ right = currentPosition;
+ effectiveHalfWidth = Epsilon;
+ return;
+ }
+
+ Vector2 defaultNormal = MainNormals[index];
+ if (defaultNormal.LengthSquared() <= Epsilon)
+ defaultNormal = Vector2.UnitY;
+
+ if (MainSettings.JoinStyle == PrimitiveJoinStyle.Flat || PositionsIndex <= 2 || index == 0 || index == PositionsIndex - 1)
+ {
+ Vector2 offset = defaultNormal * halfWidth;
+ left = currentPosition - offset;
+ right = currentPosition + offset;
+ effectiveHalfWidth = halfWidth;
+ return;
+ }
+
+ Vector2 prevNormal = MainNormals[Math.Max(index - 1, 0)];
+ if (prevNormal.LengthSquared() <= Epsilon)
+ prevNormal = defaultNormal;
+
+ Vector2 nextNormal = MainNormals[Math.Min(index + 1, PositionsIndex - 1)];
+ if (nextNormal.LengthSquared() <= Epsilon)
+ nextNormal = defaultNormal;
+
+ switch (MainSettings.JoinStyle)
+ {
+ case PrimitiveJoinStyle.Smooth:
+ {
+ Vector2 averageNormal = (prevNormal + defaultNormal + nextNormal) * (1f / 3f);
+ if (averageNormal.LengthSquared() <= Epsilon)
+ averageNormal = defaultNormal;
+
+ Vector2 offset = averageNormal.SafeNormalize(defaultNormal) * halfWidth;
+ left = currentPosition - offset;
+ right = currentPosition + offset;
+ effectiveHalfWidth = halfWidth;
+ return;
+ }
+
+ case PrimitiveJoinStyle.Miter:
+ {
+ Vector2 prev = prevNormal.SafeNormalize(defaultNormal);
+ Vector2 next = nextNormal.SafeNormalize(defaultNormal);
+ Vector2 miter = prev + next;
+ if (miter.LengthSquared() <= Epsilon)
+ miter = defaultNormal;
+
+ miter = miter.SafeNormalize(defaultNormal);
+ float denom = Vector2.Dot(miter, next);
+ if (Math.Abs(denom) < Epsilon)
+ denom = denom >= 0f ? Epsilon : -Epsilon;
+
+ float miterLength = halfWidth / denom;
+ float maxLength = halfWidth * MainSettings.JoinMiterLimit;
+ miterLength = MathHelper.Clamp(miterLength, -maxLength, maxLength);
+ Vector2 offset = miter * miterLength;
+ left = currentPosition - offset;
+ right = currentPosition + offset;
+ effectiveHalfWidth = Math.Max(Math.Abs(miterLength), Epsilon);
+ return;
+ }
+
+ default:
+ {
+ Vector2 offset = defaultNormal * halfWidth;
+ left = currentPosition - offset;
+ right = currentPosition + offset;
+ effectiveHalfWidth = halfWidth;
+ return;
+ }
+ }
+ }
+
+ private static bool TryBuildWireframeGeometry(Color lineColor, out int lineCount)
+ {
+ lineCount = 0;
+
+ if (WireframeVertices == null)
+ return false;
+
+ int segments = PositionsIndex - 1;
+ if (segments <= 0)
+ return false;
+
+ WireframeVertexCount = 0;
+
+ for (int i = 0; i < segments; i++)
+ {
+ int currentLeft = i * 2;
+ int currentRight = currentLeft + 1;
+ int nextLeft = currentLeft + 2;
+ int nextRight = nextLeft + 1;
+
+ AddWireframeLineFromIndices(currentLeft, nextLeft, lineColor);
+ AddWireframeLineFromIndices(currentRight, nextRight, lineColor);
+ }
+
+ for (int i = 0; i < PositionsIndex; i++)
+ {
+ int leftIndex = i * 2;
+ AddWireframeLineFromIndices(leftIndex, leftIndex + 1, lineColor);
+ }
+
+ lineCount = WireframeVertexCount / 2;
+ return lineCount > 0;
+ }
+
+ private static void AddWireframeLineFromIndices(int startVertexIndex, int endVertexIndex, Color color)
+ {
+ if (WireframeVertexCount + 1 >= WireframeVertices.Length)
+ return;
+
+ int vertexCount = VerticesIndex;
+ if (startVertexIndex >= vertexCount || endVertexIndex >= vertexCount)
+ return;
+
+ ref readonly VertexPosition2DColorTexture start = ref MainVertices[startVertexIndex];
+ ref readonly VertexPosition2DColorTexture end = ref MainVertices[endVertexIndex];
+ WireframeVertices[WireframeVertexCount++] = new VertexPositionColor(new Vector3(start.Position, 0f), color);
+ WireframeVertices[WireframeVertexCount++] = new VertexPositionColor(new Vector3(end.Position, 0f), color);
+ }
+
+ private static void DrawWireframe(Matrix view, Matrix projection, int lineCount)
+ {
+ if (lineCount <= 0 || WireframeEffect == null)
+ return;
+
+ WireframeEffect.World = Matrix.Identity;
+ WireframeEffect.View = view;
+ WireframeEffect.Projection = projection;
+
+ var device = Main.instance.GraphicsDevice;
+ foreach (EffectPass pass in WireframeEffect.CurrentTechnique.Passes)
+ {
+ pass.Apply();
+ device.DrawUserPrimitives(PrimitiveType.LineList, WireframeVertices, 0, lineCount);
+ }
+ }
+
+ private static void AssignIndices()
+ {
+ IndicesIndex = 0;
+
+ if (ActiveTopology == PrimitiveTopology.TriangleStrip)
+ {
+ for (short i = 0; i < VerticesIndex && IndicesIndex < MaxIndices; i++)
+ MainIndices[IndicesIndex++] = i;
+ return;
+ }
+
// What this is doing is basically representing each point on the vertices list as
// indices. These indices should come together to create a tiny rectangle that acts
// as a segment on the trail. This is achieved here by splitting the indices (or rather, points)
// into 2 triangles, which requires 6 points.
// The logic here basically determines which indices are connected together.
- IndicesIndex = 0;
- for (short i = 0; i < PositionsIndex - 2; i++)
+ for (short i = 0; i < PositionsIndex - 2 && IndicesIndex + 5 < MaxIndices; i++)
{
short connectToIndex = (short)(i * 2);
MainIndices[IndicesIndex] = connectToIndex;
@@ -306,6 +826,37 @@ namespace CalamityMod.Graphics.Primitives
MainIndices[IndicesIndex] = (short)(connectToIndex + 3);
IndicesIndex++;
}
+
+ AppendCapTriangles();
+ }
+
+ private static void AppendCapTriangles()
+ {
+ if (MainSettings.CapStyle == PrimitiveCapStyle.None)
+ return;
+
+ if (PositionsIndex <= 0)
+ return;
+
+ if (StartCapCenterIndex >= 0)
+ AddTriangle((short)(StartCapCenterIndex), 0, 1);
+
+ if (EndCapCenterIndex >= 0)
+ {
+ short leftIndex = (short)((PositionsIndex - 1) * 2);
+ short rightIndex = (short)(leftIndex + 1);
+ AddTriangle(leftIndex, rightIndex, EndCapCenterIndex);
+ }
+ }
+
+ private static void AddTriangle(short i0, short i1, short i2)
+ {
+ if (IndicesIndex + 2 >= MaxIndices)
+ return;
+
+ MainIndices[IndicesIndex++] = i0;
+ MainIndices[IndicesIndex++] = i1;
+ MainIndices[IndicesIndex++] = i2;
}
private static void CalcuatePixelatedPerspectiveMatrices(out Matrix viewMatrix, out Matrix projectionMatrix)
@@ -314,6 +865,8 @@ namespace CalamityMod.Graphics.Primitives
projectionMatrix = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -1, 1);
viewMatrix = Matrix.Identity;
}
+
+ private static float Cross(Vector2 a, Vector2 b) => a.X * b.Y - a.Y * b.X;
#endregion
}
}
diff --git a/Graphics/Primitives/PrimitiveSettings.cs b/Graphics/Primitives/PrimitiveSettings.cs
index f5fb74f5a1..ebc4b51fcd 100644
--- a/Graphics/Primitives/PrimitiveSettings.cs
+++ b/Graphics/Primitives/PrimitiveSettings.cs
@@ -1,8 +1,125 @@
-using Microsoft.Xna.Framework;
+using System;
+using Microsoft.Xna.Framework;
using Terraria.Graphics.Shaders;
namespace CalamityMod.Graphics.Primitives
{
+ ///
+ /// Controls how U texture coordinates are generated for primitive ribbons.
+ ///
+ public enum PrimitiveTextureMode
+ {
+ ///
+ /// U coordinates run from 0 to 1 across the full trail length. This matches the legacy behavior.
+ ///
+ Normalized,
+
+ ///
+ /// U coordinates advance according to distance along the trail. One full texture cycle occurs every pixels.
+ ///
+ Distance
+ }
+
+ ///
+ /// Controls how adjacent segments are joined together when expanding points into quads.
+ ///
+ public enum PrimitiveJoinStyle
+ {
+ ///
+ /// Legacy behavior. Each segment is expanded using its forward direction only.
+ ///
+ Flat,
+
+ ///
+ /// Uses the averaged tangent of neighbouring segments to smooth corners.
+ ///
+ Smooth,
+
+ ///
+ /// Uses a mitered join to keep width continuous around sharp corners.
+ ///
+ Miter
+ }
+
+ ///
+ /// Determines how intermediate sample points are generated for smoothing.
+ ///
+ public enum PrimitiveSmoothingType
+ {
+ ///
+ /// Classic Catmull-Rom interpolation between points.
+ ///
+ CatmullRom,
+
+ ///
+ /// Cardinal spline interpolation with configurable tension.
+ ///
+ Cardinal,
+
+ ///
+ /// Straight-line interpolation between neighbouring points.
+ ///
+ Linear,
+
+ ///
+ /// Cubic Hermite interpolation using central difference tangents.
+ ///
+ Hermite,
+
+ ///
+ /// Cubic Bezier interpolation using Catmull-Rom handles.
+ ///
+ CubicBezier
+ }
+
+ ///
+ /// Selects how orientation frames propagate along the trail.
+ ///
+ public enum PrimitiveFrameTransportMode
+ {
+ ///
+ /// Derives the normal from the instantaneous tangent (legacy behaviour).
+ ///
+ Basic,
+
+ ///
+ /// Uses parallel transport to minimise twisting.
+ ///
+ ParallelTransport
+ }
+
+ ///
+ /// Determines the topology used when submitting geometry to the GPU.
+ ///
+ public enum PrimitiveTopology
+ {
+ ///
+ /// Expands geometry into independent triangles (legacy behaviour).
+ ///
+ TriangleList,
+
+ ///
+ /// Connects geometry using a continuous triangle strip.
+ ///
+ TriangleStrip
+ }
+
+ ///
+ /// Controls how the start and end of the primitive are capped.
+ ///
+ public enum PrimitiveCapStyle
+ {
+ ///
+ /// Leaves the ribbon open (legacy behaviour).
+ ///
+ None,
+
+ ///
+ /// Adds a flat triangular cap across the ribbon ends.
+ ///
+ Flat
+ }
+
///
/// Contains all the various options to use when creating a primitive trail. New members can be added freely without breaking existing implementations.
///
@@ -72,6 +189,76 @@ namespace CalamityMod.Graphics.Primitives
/// An optional override to force the trail to use the provided positions as the side positions of the initial vertex. They are the left and right positions respectively.
///
public readonly (Vector2, Vector2)? InitialVertexPositionsOverride;
+
+ ///
+ /// Determines how U texture coordinates are generated.
+ ///
+ public readonly PrimitiveTextureMode TextureCoordinateMode;
+
+ ///
+ /// Controls the scale of generated U coordinates. In this is a multiplier, in this is the distance (in pixels) for one full texture cycle.
+ ///
+ public readonly float TextureCycleLength;
+
+ ///
+ /// Adds an additional offset to the generated U coordinate. In distance mode this value is interpreted in pixels.
+ ///
+ public readonly float TextureScrollOffset;
+
+ ///
+ /// Allows overriding the automatically generated U coordinate with a custom function. Receives the normalized completion ratio (0-1) and should return the desired U coordinate.
+ ///
+ public readonly Func TextureCoordinateFunction;
+
+ ///
+ /// Determines how consecutive segments are joined together when expanding into quads.
+ ///
+ public readonly PrimitiveJoinStyle JoinStyle;
+
+ ///
+ /// Maximum multiplier applied to miter joins to keep spikes under control.
+ ///
+ public readonly float JoinMiterLimit;
+
+ ///
+ /// If true, a debug wireframe will be rendered on top of the primitive.
+ ///
+ public readonly bool DebugWireframe;
+
+ ///
+ /// The color used for the optional wireframe overlay.
+ ///
+ public readonly Color WireframeColor;
+
+ ///
+ /// Determines the interpolation style when smoothing the provided point list.
+ ///
+ public readonly PrimitiveSmoothingType SmoothingType;
+
+ ///
+ /// Controls how many intermediate subdivisions are generated per control segment when smoothing. Set to 0 for automatic distribution.
+ ///
+ public readonly int SmoothingSegments;
+
+ ///
+ /// Additional tension used by smoothing functions that support it (e.g. Cardinal splines).
+ ///
+ public readonly float SmoothingTension;
+
+ ///
+ /// Determines how normals are transported along the curve.
+ ///
+ public readonly PrimitiveFrameTransportMode FrameTransportMode;
+
+ ///
+ /// Chooses the primitive topology when submitting geometry to the GPU.
+ ///
+ public readonly PrimitiveTopology Topology;
+
+ ///
+ /// Determines how the ribbon is capped at its extremities.
+ ///
+ public readonly PrimitiveCapStyle CapStyle;
#endregion
///
@@ -85,7 +272,21 @@ namespace CalamityMod.Graphics.Primitives
/// The shader to apply when rendering the primitives.
/// Whether to use unscaled perspective matrices when rendering primitives. Recommended when using this system outside of its typical context; i.e. rendering primitives in the background via a CustomSky.
/// An optional override to force the trail to use the provided positions as the side positions of the initial vertex. They are the left and right positions respectively and should be in screen space.
- public PrimitiveSettings(VertexWidthFunction widthFunction, VertexColorFunction colorFunction, VertexOffsetFunction offsetFunction = null, bool smoothen = true, bool pixelate = false, MiscShaderData shader = null, bool useUnscaledMatrices = false, (Vector2, Vector2)? initialVertexPositionsOverride = null)
+ /// Determines how U texture coordinates are generated.
+ /// Controls how fast U coordinates advance. Acts as a multiplier in normalized mode, or the distance per cycle in distance mode.
+ /// Adds an offset to generated U coordinates. Interpreted in pixels when using distance mode.
+ /// Optional override that receives the completion ratio and returns a custom U coordinate.
+ /// Determines how neighbouring segments are joined when expanding into quads.
+ /// Maximum multiplier applied to miter joins to prevent spikes. Only used when is .
+ /// When true, draws a wireframe overlay useful for debugging primitive geometry.
+ /// Optional override for the wireframe color. If null, a vivid green is used.
+ /// Determines the interpolation style used when smoothing the control points.
+ /// When greater than zero, specifies the number of subdivisions created per control edge.
+ /// Optional tension parameter used by certain smoothing types such as cardinal splines.
+ /// Controls how frame orientation is propagated along the curve.
+ /// Specifies the primitive topology used when submitting geometry.
+ /// Selects how the ribbon's start and end are capped.
+ public PrimitiveSettings(VertexWidthFunction widthFunction, VertexColorFunction colorFunction, VertexOffsetFunction offsetFunction = null, bool smoothen = true, bool pixelate = false, MiscShaderData shader = null, bool useUnscaledMatrices = false, (Vector2, Vector2)? initialVertexPositionsOverride = null, PrimitiveTextureMode textureCoordinateMode = PrimitiveTextureMode.Normalized, float textureCycleLength = 1f, float textureScrollOffset = 0f, Func textureCoordinateFunction = null, PrimitiveJoinStyle joinStyle = PrimitiveJoinStyle.Smooth, float joinMiterLimit = 4f, bool debugWireframe = false, Color? wireframeColor = null, PrimitiveSmoothingType smoothingType = PrimitiveSmoothingType.CatmullRom, int smoothingSegments = 0, float smoothingTension = 0f, PrimitiveFrameTransportMode frameTransportMode = PrimitiveFrameTransportMode.ParallelTransport, PrimitiveTopology topology = PrimitiveTopology.TriangleStrip, PrimitiveCapStyle capStyle = PrimitiveCapStyle.None)
{
WidthFunction = widthFunction;
ColorFunction = colorFunction;
@@ -95,6 +296,20 @@ namespace CalamityMod.Graphics.Primitives
Shader = shader;
UseUnscaledMatrices = useUnscaledMatrices;
InitialVertexPositionsOverride = initialVertexPositionsOverride;
+ TextureCoordinateMode = textureCoordinateMode;
+ TextureCycleLength = Math.Abs(textureCycleLength) <= PrimitiveRenderer.Epsilon ? 1f : textureCycleLength;
+ TextureScrollOffset = textureScrollOffset;
+ TextureCoordinateFunction = textureCoordinateFunction;
+ JoinStyle = joinStyle;
+ JoinMiterLimit = Math.Max(joinMiterLimit, 1f);
+ DebugWireframe = debugWireframe;
+ WireframeColor = wireframeColor ?? Color.LimeGreen;
+ SmoothingType = smoothingType;
+ SmoothingSegments = Math.Max(smoothingSegments, 0);
+ SmoothingTension = smoothingTension;
+ FrameTransportMode = frameTransportMode;
+ Topology = topology;
+ CapStyle = PrimitiveCapStyle.Flat;
}
}
}
diff --git a/Graphics/Renderers/RendererManager.cs b/Graphics/Renderers/RendererManager.cs
index 642ccce355..9665bab61b 100644
--- a/Graphics/Renderers/RendererManager.cs
+++ b/Graphics/Renderers/RendererManager.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Enums;
+using CalamityMod.Systems.Graphic;
using CalamityMod.Utilities.Daybreak;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -26,7 +27,8 @@ namespace CalamityMod.Graphics.Renderers
return;
// This hooks here, because doing it any sooner causes the screen position to be a frame behind.
- On_Main.CheckMonoliths += DrawToTargets;
+ GeneralDrawLayerSystem.OnDrawLayer += DrawRendererAtLayer;
+ GeneralDrawLayerSystem.OnPrepareDraw += DrawToTargets;
}
public override void Unload()
@@ -60,7 +62,7 @@ namespace CalamityMod.Graphics.Renderers
#endregion
#region Drawing
- internal static void DrawRendererAtLayer(GeneralDrawLayer drawLayer)
+ private static void DrawRendererAtLayer(GeneralDrawLayer drawLayer)
{
var renderers = Renderers.Where(renderer => renderer.ShouldDraw && renderer.Layer == drawLayer);
if (renderers.Any())
@@ -74,10 +76,8 @@ namespace CalamityMod.Graphics.Renderers
}
}
- private void DrawToTargets(On_Main.orig_CheckMonoliths orig)
+ private void DrawToTargets()
{
- orig();
-
if (Main.gameMenu || Main.dedServ)
return;
diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs
index 0d5d3b2b50..0c5c041075 100644
--- a/ILEditing/ILChangesLoading.cs
+++ b/ILEditing/ILChangesLoading.cs
@@ -55,15 +55,6 @@ namespace CalamityMod.ILEditing
IL_TileDrawing.DrawTrees += DrawTreeGlowMask;
On_TileDrawing.DrawBasicTile += DrawTreeTrunkAndCactusGlowMask;
- // Graphics (GeneralDrawLayer detours)
- On_Main.DrawBackgroundBlackFill += GeneralDrawLayer_DrawToLayer_BeforeAllTiles;
- On_Main.DoDraw_Tiles_Solid += GeneralDrawLayer_DrawToLayer_BeforeSolidTiles;
- On_Main.DoDraw_DrawNPCsOverTiles += GeneralDrawLayer_DrawToLayer_NPCs;
- On_Main.DrawProjectiles += GeneralDrawLayer_DrawToLayer_Projectiles;
- On_Main.DrawPlayers_AfterProjectiles += GeneralDrawLayer_DrawToLayer_AfterPlayers;
- On_Main.DrawDust += GeneralDrawLayer_DrawToLayer_AfterDusts;
- On_Main.DrawInfernoRings += GeneralDrawLayer_DrawToLayer_AfterEverything;
-
// NPC behavior
IL_Main.UpdateTime += PermitNighttimeTownNPCSpawning;
On_Main.UpdateTime_SpawnTownNPCs += AlterTownNPCSpawnRate;
diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs
index abbf86fdd0..0afb4a96a3 100644
--- a/ILEditing/MechanicILChanges.cs
+++ b/ILEditing/MechanicILChanges.cs
@@ -7,9 +7,6 @@ using CalamityMod.DataStructures;
using CalamityMod.Enums;
using CalamityMod.Events;
using CalamityMod.FluidSimulation;
-using CalamityMod.Graphics.Metaballs;
-using CalamityMod.Graphics.Primitives;
-using CalamityMod.Graphics.Renderers;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Armor.Wulfrum;
using CalamityMod.Items.Critters;
@@ -27,7 +24,6 @@ using CalamityMod.Projectiles;
using CalamityMod.Projectiles.Ranged;
using CalamityMod.Projectiles.Typeless;
using CalamityMod.Systems;
-using CalamityMod.Systems.Graphic.PixelationSystem;
using CalamityMod.Systems.Mechanic;
using CalamityMod.Tiles;
using CalamityMod.Utilities.Daybreak;
@@ -863,72 +859,6 @@ namespace CalamityMod.ILEditing
}
#endregion
- #region GeneralDrawLayer Systems Drawing
- private static void GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer drawLayer)
- {
- GeneralParticleHandler.DrawParticleCollectionsAtSpecificLayer(drawLayer);
-
- Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
- MetaballManager.DrawMetaballs(drawLayer);
- Main.spriteBatch.End();
-
- PrimitivePixelationSystem.DrawTargetScaled(drawLayer);
-
- PixelationManager.DrawPixelatedTargets(drawLayer);
-
- RendererManager.DrawRendererAtLayer(drawLayer);
-
- }
-
- private static void GeneralDrawLayer_DrawToLayer_BeforeAllTiles(On_Main.orig_DrawBackgroundBlackFill orig, Main self)
- {
- Main.spriteBatch.End(out var ss);
- GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.BeforeAllTiles);
- Main.spriteBatch.Begin(ss);
- orig(self);
- }
-
- private static void GeneralDrawLayer_DrawToLayer_BeforeSolidTiles(On_Main.orig_DoDraw_Tiles_Solid orig, Main self)
- {
- GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.BeforeSolidTiles);
- orig(self);
- }
-
- private static void GeneralDrawLayer_DrawToLayer_NPCs(On_Main.orig_DoDraw_DrawNPCsOverTiles orig, Main self)
- {
- GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.BeforeNPCs);
- orig(self);
- GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.AfterNPCs);
- }
-
- private static void GeneralDrawLayer_DrawToLayer_Projectiles(On_Main.orig_DrawProjectiles orig, Main self)
- {
- GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.BeforeProjectiles);
- orig(self);
- GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.AfterProjectiles);
- }
-
- private static void GeneralDrawLayer_DrawToLayer_AfterPlayers(On_Main.orig_DrawPlayers_AfterProjectiles orig, Main self)
- {
- orig(self);
- GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.AfterPlayers);
- }
-
- private static void GeneralDrawLayer_DrawToLayer_AfterDusts(On_Main.orig_DrawDust orig, Main self)
- {
- orig(self);
- GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.AfterDusts);
- }
-
- private static void GeneralDrawLayer_DrawToLayer_AfterEverything(On_Main.orig_DrawInfernoRings orig, Main self)
- {
- orig(self);
- Main.spriteBatch.End(out var ss);
- GeneralDrawLayer_DrawForSupportedSystems(GeneralDrawLayer.AfterEverything);
- Main.spriteBatch.Begin(ss);
- }
- #endregion
-
#region General Particle Rendering
private static void DrawFusableParticles(On_Main.orig_SortDrawCacheWorms orig, Main self)
{
diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs
index e08af942c8..4c0b0af606 100644
--- a/Items/CalamityGlobalItem.cs
+++ b/Items/CalamityGlobalItem.cs
@@ -24,7 +24,6 @@ using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.NPCs.Other;
using CalamityMod.NPCs.TownNPCs;
-using CalamityMod.Packets;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Healing;
using CalamityMod.Projectiles.Magic;
@@ -36,7 +35,6 @@ using CalamityMod.Systems.Collections;
using CalamityMod.Tiles.Furniture.CraftingStations;
using CalamityMod.UI;
using CalamityMod.UI.CalamitasEnchants;
-using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -46,7 +44,6 @@ using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
-using Terraria.Utilities;
using static Terraria.ModLoader.ModContent;
namespace CalamityMod.Items
@@ -59,12 +56,18 @@ namespace CalamityMod.Items
/// Tracks the stealth strike damage modifier for this item, derived from its prefix.
internal float StealthStrikePrefixBonus;
+ private BitsByte flag0 = 0;
+
#region Chargeable Item Variables
///
/// If set to true, this item will consume on use.
/// Be sure to also set and .
///
- public bool UsesCharge = false;
+ public bool UsesCharge
+ {
+ get => flag0[0];
+ set => flag0[0] = value;
+ }
/// The current charge value of this item.
public float Charge = 0f;
/// The maximum charge value of this item. Should only be set if is set to true.
@@ -88,7 +91,11 @@ namespace CalamityMod.Items
#region Enchantment Variables
/// If set to true, this item cannot receive enchantments from the Brimstone Witch.
- public bool CannotBeEnchanted = false;
+ public bool CannotBeEnchanted
+ {
+ get => flag0[1];
+ set => flag0[1] = value;
+ }
/// Stores the current enchantment placed on this item. If set to null, this item has no enchantment.
public Enchantment? AppliedEnchantment = null;
///
@@ -117,22 +124,29 @@ namespace CalamityMod.Items
/// Set to true if this item can only be obtained in Revengeance Mode.
/// Adds "Revengeance" to the bottom of the item's tooltip.
///
- public bool revengeanceItem = false;
+ public bool revengeanceItem
+ {
+ get => flag0[2];
+ set => flag0[2] = value;
+ }
///
/// Set to true if this item is dedicated to a Patreon donator.
/// Adds "- Donor Item -" to the bottom of the item's tooltip.
///
- public bool donorItem = false;
+ public bool donorItem
+ {
+ get => flag0[3];
+ set => flag0[3] = value;
+ }
///
/// Set to true if this item is dedicated to a Calamity developer.
/// Adds "- Dev Item -" to the bottom of the item's tooltip.
///
- public bool devItem = false;
- ///
- /// If set to a value greater than 1, applies a multiplier to the item's grab range.
- /// Used by coin items spawned from hitting ricoshot coins.
- ///
- public float grabRangeMultiplier = 1f;
+ public bool devItem
+ {
+ get => flag0[4];
+ set => flag0[4] = value;
+ }
public static readonly Color ExhumedTooltipColor = new Color(198, 27, 64);
@@ -152,6 +166,9 @@ namespace CalamityMod.Items
{
CalamityGlobalItem myClone = (CalamityGlobalItem)base.Clone(item, itemClone);
+ // BitFlags
+ myClone.flag0 = flag0;
+
// Rogue
myClone.StealthStrikePrefixBonus = StealthStrikePrefixBonus;
@@ -163,16 +180,9 @@ namespace CalamityMod.Items
myClone.ChargePerAltUse = ChargePerAltUse;
// Enchantments
- myClone.CannotBeEnchanted = CannotBeEnchanted;
myClone.AppliedEnchantment = AppliedEnchantment.HasValue ? AppliedEnchantment.Value : null;
myClone.DischargeEnchantExhaustion = DischargeEnchantExhaustion;
- // Miscellaneous
- myClone.revengeanceItem = revengeanceItem;
- myClone.donorItem = donorItem;
- myClone.devItem = devItem;
- myClone.grabRangeMultiplier = grabRangeMultiplier;
-
return myClone;
}
@@ -1462,8 +1472,8 @@ namespace CalamityMod.Items
public override void GrabRange(Item item, Player player, ref int grabRange)
{
// First, apply the grab range multiplier.
- if (grabRangeMultiplier > 1f)
- grabRange = (int)(grabRangeMultiplier * grabRange);
+ if (item.TryGetGlobalItem(out var grabRangeItem) && grabRangeItem.grabRangeMultiplier > 1f)
+ grabRange = (int)(grabRangeItem.grabRangeMultiplier * grabRange);
// Then, apply flat grab range boosts.
if (player.Calamity().reaverExplore)
@@ -1609,9 +1619,6 @@ namespace CalamityMod.Items
private static int cachedForgeID = -1;
public override void OnCreated(Item item, ItemCreationContext context)
{
- // ChoosePrefix also happens on craft so go reset it here too
- storedPrefix = -1;
-
// 05JUL2024: Ozzatron: Register the usage of Draedon's Forge for the purposes of his dialogue.
// This was moved out of an On edit in the DraedonsForge item for Magic Storage compatibility.
Player p = Main.LocalPlayer;
@@ -1622,73 +1629,6 @@ namespace CalamityMod.Items
}
#endregion
- #region Reforge Mechanic Rework
- private static int storedPrefix = -1;
- public override void PreReforge(Item item)
- {
- StealthStrikePrefixBonus = 0f;
- storedPrefix = item.prefix;
- }
-
- // Ozzatron 31AUG2022: total rework to the reforge rework for mod compatibility
- // you can now disable the rework with config in case it isn't enough to solve your conflicts
- // removed data saved on items; reforging is now a coalescing flowchart that has no RNG
- public override int ChoosePrefix(Item item, UnifiedRandom rand)
- {
- if (storedPrefix == -1 && item.CountsAsClass() && (item.maxStack == 1 || item.AllowReforgeForStackableItem))
- {
- // Crafting (or first reforge of) a rogue weapon has a 75% chance for a random modifier, this check is done by vanilla
- // Negative modifiers have a 66.66% chance of being voided, Annoying modifier is intentionally ignored by vanilla
- int prefix = CalamityUtils.RandomRoguePrefix();
- bool keepPrefix = !CalamityUtils.NegativeRoguePrefix(prefix) || Main.rand.NextBool(3);
- return keepPrefix ? prefix : 0;
- }
-
- if (Main.gameMenu)
- return -1;
-
- if (item.accessory)
- {
- return CalamityUtils.GetAccessoryReforge(item, rand, storedPrefix);
- }
- else
- {
- if (CalamityServerConfig.Instance.RemoveReforgeRNG && storedPrefix != -1)
- {
- return CalamityUtils.GetReworkedReforge(item, rand, storedPrefix);
- }
- }
-
- return -1;
- }
-
- public override void PostReforge(Item item)
- {
- storedPrefix = -1;
- // Bandit steals 20% of the total price of the reforge if she's around.
- if (NPC.AnyNPCs(NPCType()))
- {
- // Calculate the item's reforge cost.
- int value = item.value;
- Player p = Main.LocalPlayer;
- ItemLoader.ReforgePrice(item, ref value, ref p.discountAvailable);
-
- // Steal 20% of that money.
- int stolen = value / 5;
- CalamityWorld.MoneyStolenByBandit += stolen;
-
- // Increment the reforge counter to allow the Bandit to refund
- // Also triggers Tinkerer dialogue that hints to the player that money is being stolen
- CalamityWorld.Reforges++;
-
- if (Main.netMode == NetmodeID.MultiplayerClient)
- {
- BanditStolenMoneySyncPacket.Send(stolen);
- }
- }
- }
- #endregion
-
#region Rarity Price Table
// Base numeric rarity pricing guide.
private static readonly int Rarity0BuyPrice = Item.buyPrice(0, 0, 50, 0);
@@ -1753,6 +1693,13 @@ namespace CalamityMod.Items
public static int RarityCalamityRedBuyPrice => Rarity17BuyPrice;
#endregion
+ #region PreReforge
+ public override void PreReforge(Item item)
+ {
+ StealthStrikePrefixBonus = 0f;
+ }
+ #endregion
+
//
// !! WARNING !!
//
diff --git a/Items/GrabRangeGlobalItem.cs b/Items/GrabRangeGlobalItem.cs
new file mode 100644
index 0000000000..8236179656
--- /dev/null
+++ b/Items/GrabRangeGlobalItem.cs
@@ -0,0 +1,37 @@
+using Terraria;
+using Terraria.ID;
+using Terraria.ModLoader;
+
+namespace CalamityMod.Items;
+
+internal sealed class GrabRangeGlobalItem : GlobalItem
+{
+ ///
+ /// If set to a value greater than 1, applies a multiplier to the item's grab range.
+ /// Used by coin items spawned from hitting ricoshot coins.
+ ///
+ public float grabRangeMultiplier = 1f;
+
+ public override bool InstancePerEntity => true;
+
+ public override bool AppliesToEntity(Item entity, bool lateInstantiation)
+ {
+ return entity.type switch
+ {
+ ItemID.CopperCoin
+ or ItemID.SilverCoin
+ or ItemID.GoldCoin
+ or ItemID.PlatinumCoin => true,
+ _ => false,
+ };
+ }
+
+ public override GlobalItem Clone(Item item, Item itemClone)
+ {
+ GrabRangeGlobalItem myClone = (GrabRangeGlobalItem)base.Clone(item, itemClone);
+ myClone.grabRangeMultiplier = grabRangeMultiplier;
+ return myClone;
+ }
+
+ // GrabRange hook is Placed in CalamityGlobalItem for sake of ordering
+}
diff --git a/Items/Weapons/Ranged/AquashardShotgun.cs b/Items/Weapons/Ranged/AquashardShotgun.cs
deleted file mode 100644
index e2a590fafb..0000000000
--- a/Items/Weapons/Ranged/AquashardShotgun.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using CalamityMod.Items.Materials;
-using CalamityMod.Items.Placeables.SunkenSea;
-using CalamityMod.Projectiles.Ranged;
-using Microsoft.Xna.Framework;
-using Terraria;
-using Terraria.DataStructures;
-using Terraria.ID;
-using Terraria.ModLoader;
-
-namespace CalamityMod.Items.Weapons.Ranged
-{
- public class AquashardShotgun : ModItem, ILocalizedModType
- {
- public new string LocalizationCategory => "Items.Weapons.Ranged";
- public override void SetDefaults()
- {
- Item.width = 62;
- Item.height = 26;
- Item.damage = 12;
- Item.DamageType = DamageClass.Ranged;
- Item.useTime = 30;
- Item.useAnimation = 30;
- Item.useStyle = ItemUseStyleID.Shoot;
- Item.noMelee = true;
- Item.knockBack = 5.5f;
- Item.value = CalamityGlobalItem.RarityOrangeBuyPrice;
- Item.rare = ItemRarityID.Orange;
- Item.UseSound = SoundID.Item61;
- Item.autoReuse = true;
- Item.shoot = ModContent.ProjectileType();
- Item.shootSpeed = 30f;
- Item.useAmmo = AmmoID.Bullet;
- }
-
- // Terraria seems to really dislike high crit values in SetDefaults
- public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 6;
-
- public override Vector2? HoldoutOffset() => new Vector2(-10, 0);
-
- public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
- {
- for (int index = 0; index < 2; ++index)
- {
- float SpeedX = velocity.X + Main.rand.Next(-40, 41) * 0.05f;
- float SpeedY = velocity.Y + Main.rand.Next(-40, 41) * 0.05f;
-
- if (type == ProjectileID.Bullet)
- {
- int projectile = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockback, player.whoAmI);
- Main.projectile[projectile].timeLeft = 200;
- }
- else
- Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI);
- }
- return false;
- }
-
- public override void AddRecipes()
- {
- CreateRecipe().
- AddIngredient(ItemID.Boomstick).
- AddIngredient(2).
- AddIngredient(10).
- AddTile(TileID.Anvils).
- Register();
- }
- }
-}
diff --git a/Items/Weapons/Ranged/AquashardShotgun.png b/Items/Weapons/Ranged/AquashardShotgun.png
deleted file mode 100644
index 516b1fa7cc..0000000000
Binary files a/Items/Weapons/Ranged/AquashardShotgun.png and /dev/null differ
diff --git a/Items/Weapons/Ranged/Shardshocker.cs b/Items/Weapons/Ranged/Shardshocker.cs
new file mode 100644
index 0000000000..1223124a57
--- /dev/null
+++ b/Items/Weapons/Ranged/Shardshocker.cs
@@ -0,0 +1,99 @@
+using System;
+using CalamityMod.Items.Materials;
+using CalamityMod.Items.Placeables.SunkenSea;
+using CalamityMod.NPCs.SunkenSea;
+using CalamityMod.Projectiles.Ranged;
+using Microsoft.Xna.Framework;
+using Terraria;
+using Terraria.Audio;
+using Terraria.DataStructures;
+using Terraria.ID;
+using Terraria.ModLoader;
+
+namespace CalamityMod.Items.Weapons.Ranged
+{
+ public class Shardshocker : ModItem, ILocalizedModType
+ {
+ public new string LocalizationCategory => "Items.Weapons.Ranged";
+ public static readonly SoundStyle ShootAndReloadSound = new("CalamityMod/Sounds/Item/WulfrumBlunderbussFireAndReload") { PitchVariance = 0.25f };
+ public override void SetDefaults()
+ {
+ Item.width = 86;
+ Item.height = 44;
+ Item.damage = 131;
+ Item.DamageType = DamageClass.Ranged;
+ Item.useTime = 60;
+ Item.useAnimation = 60;
+ Item.useStyle = ItemUseStyleID.Shoot;
+ Item.noMelee = true;
+ Item.knockBack = 5.5f;
+ Item.value = CalamityGlobalItem.RarityOrangeBuyPrice;
+ Item.rare = ItemRarityID.Orange;
+ Item.UseSound = null;
+ Item.autoReuse = true;
+ Item.shoot = ModContent.ProjectileType();
+ Item.shootSpeed = 50f;
+ }
+
+ // Terraria seems to really dislike high crit values in SetDefaults
+ public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 6;
+
+ public override Vector2? HoldoutOffset() => new Vector2(-10, 0);
+
+ public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
+ {
+ SoundEngine.PlaySound(ShootAndReloadSound with { PitchVariance = 0.3f }, position);
+ SoundEngine.PlaySound(GiantClam.SlamSound with { Pitch = 0.2f }, position);
+ Projectile.NewProjectile(source, position, velocity, Item.shoot, damage, knockback, player.whoAmI);
+ return false;
+ }
+ public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true;
+
+ public override void UseStyle(Player player, Rectangle heldItemFrame)
+ {
+ player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X));
+ float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir;
+
+ Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 41f;
+ Vector2 itemSize = new Vector2(Item.width, Item.height);
+ Vector2 itemOrigin = new Vector2(4, 1);
+
+ CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin);
+ base.UseStyle(player, heldItemFrame);
+ }
+
+ // Recoil + Not having the gun aim downwards
+ public override void UseItemFrame(Player player)
+ {
+ player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X));
+
+ float animProgress = 1 - player.itemTime / (float)player.itemTimeMax;
+ float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2;
+ if (animProgress < 0.5)
+ rotation += (player.altFunctionUse == 2 ? -1f : -0.45f) * (float)Math.Pow((0.5f - animProgress) / 0.5f, 2) * player.direction;
+ player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); //must be here otherwise it will vibrate
+
+
+ //Reloads the gun
+ if (animProgress > 0.5f)
+ {
+ float backArmRotation = rotation + 0.52f * player.direction;
+
+ Player.CompositeArmStretchAmount stretch = ((float)Math.Sin(MathHelper.Pi * (animProgress - 0.5f) / 0.36f)).ToStretchAmount();
+ player.SetCompositeArmBack(true, stretch, backArmRotation);
+ }
+
+ }
+
+ public override void AddRecipes()
+ {
+ CreateRecipe().
+ AddIngredient().
+ AddIngredient(5).
+ AddIngredient(15).
+ AddIngredient(2).
+ AddTile(TileID.Anvils).
+ Register();
+ }
+ }
+}
diff --git a/Items/Weapons/Ranged/Shardshocker.png b/Items/Weapons/Ranged/Shardshocker.png
new file mode 100644
index 0000000000..dc5fde0017
Binary files /dev/null and b/Items/Weapons/Ranged/Shardshocker.png differ
diff --git a/Items/Weapons/Ranged/TheBlunderbass.cs b/Items/Weapons/Ranged/TheBlunderbass.cs
new file mode 100644
index 0000000000..d29689df96
--- /dev/null
+++ b/Items/Weapons/Ranged/TheBlunderbass.cs
@@ -0,0 +1,101 @@
+using System;
+using CalamityMod.Items.Materials;
+using CalamityMod.Items.Placeables.FurnitureDriftwood;
+using CalamityMod.Items.Placeables.SunkenSea;
+using CalamityMod.NPCs.SunkenSea;
+using CalamityMod.Projectiles.Ranged;
+using Microsoft.Xna.Framework;
+using Terraria;
+using Terraria.Audio;
+using Terraria.DataStructures;
+using Terraria.ID;
+using Terraria.ModLoader;
+
+namespace CalamityMod.Items.Weapons.Ranged
+{
+ [LegacyName("AquashardShotgun")]
+ public class TheBlunderbass : ModItem, ILocalizedModType
+ {
+ public new string LocalizationCategory => "Items.Weapons.Ranged";
+ public static readonly SoundStyle ShootAndReloadSound = new("CalamityMod/Sounds/Item/WulfrumBlunderbussFireAndReload") { PitchVariance = 0.25f };
+ public override void SetDefaults()
+ {
+ Item.width = 56;
+ Item.height = 26;
+ Item.damage = 35;
+ Item.DamageType = DamageClass.Ranged;
+ Item.useTime = 55;
+ Item.useAnimation = 55;
+ Item.useStyle = ItemUseStyleID.Shoot;
+ Item.noMelee = true;
+ Item.knockBack = 5.5f;
+ Item.value = CalamityGlobalItem.RarityOrangeBuyPrice;
+ Item.rare = ItemRarityID.Orange;
+ Item.UseSound = null;
+ Item.autoReuse = true;
+ Item.shoot = ModContent.ProjectileType();
+ Item.shootSpeed = 25f;
+ }
+
+ // Terraria seems to really dislike high crit values in SetDefaults
+ public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 6;
+
+ public override Vector2? HoldoutOffset() => new Vector2(-10, 0);
+
+ public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
+ {
+ SoundEngine.PlaySound(ShootAndReloadSound with { PitchVariance = 0.3f }, position);
+ SoundEngine.PlaySound(GiantClam.SlamSound with { Pitch = 0.2f }, position);
+ Projectile.NewProjectile(source, position, velocity, Item.shoot, damage, knockback, player.whoAmI);
+ return false;
+ }
+ public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true;
+
+ public override void UseStyle(Player player, Rectangle heldItemFrame)
+ {
+ player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X));
+ float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir;
+
+ Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 41f;
+ Vector2 itemSize = new Vector2(Item.width, Item.height);
+ Vector2 itemOrigin = new Vector2(4, 1);
+
+ CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin);
+ base.UseStyle(player, heldItemFrame);
+ }
+
+ // Recoil + Not having the gun aim downwards
+ public override void UseItemFrame(Player player)
+ {
+ player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X));
+
+ float animProgress = 1 - player.itemTime / (float)player.itemTimeMax;
+ float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2;
+ if (animProgress < 0.5)
+ rotation += (player.altFunctionUse == 2 ? -1f : -0.45f) * (float)Math.Pow((0.5f - animProgress) / 0.5f, 2) * player.direction;
+ player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); //must be here otherwise it will vibrate
+
+
+ //Reloads the gun
+ if (animProgress > 0.5f)
+ {
+ float backArmRotation = rotation + 0.52f * player.direction;
+
+ Player.CompositeArmStretchAmount stretch = ((float)Math.Sin(MathHelper.Pi * (animProgress - 0.5f) / 0.36f)).ToStretchAmount();
+ player.SetCompositeArmBack(true, stretch, backArmRotation);
+ }
+
+ }
+
+ public override void AddRecipes()
+ {
+ CreateRecipe().
+ AddIngredient().
+ AddIngredient(15).
+ AddIngredient(3).
+ AddIngredient(7).
+ AddTile(TileID.Anvils).
+ Register();
+ }
+ }
+}
diff --git a/Items/Weapons/Ranged/TheBlunderbass.png b/Items/Weapons/Ranged/TheBlunderbass.png
new file mode 100644
index 0000000000..255af4609d
Binary files /dev/null and b/Items/Weapons/Ranged/TheBlunderbass.png differ
diff --git a/Localization/en-US/Mods.CalamityMod.Configs.hjson b/Localization/en-US/Mods.CalamityMod.Configs.hjson
index f7c39ffaf6..4083c303e5 100644
--- a/Localization/en-US/Mods.CalamityMod.Configs.hjson
+++ b/Localization/en-US/Mods.CalamityMod.Configs.hjson
@@ -369,12 +369,8 @@ CalamityClientConfig: {
}
TileTextureBlendingQuality: {
- Label: "[i:GlowPaint] Tile Blending Quality"
- Tooltip:
- '''
- Change quality of tile merge soft-blending renderer.
- This controls the quality of soft-blending between different types of merged tile.
- '''
+ Label: "[i:GlowPaint] Tile Merge Soft Blending"
+ Tooltip: Changes the quality of the soft-blending renderer used when different types of tiles merge together.
}
VanillaCooldownDisplay: {
@@ -610,21 +606,21 @@ TileBlendingQuality: {
Tooltip: ""
Disable: {
- Label: Disable
- Tooltip: Disable Tile Texture Soft Blending
+ Label: Disabled
+ Tooltip: Tile texture soft blending is disabled.
}
Normal: {
- Label: Normal
- Tooltip: Enable Tile Texture Soft Blending
+ Label: Enabled
+ Tooltip: Tile texture soft blending is enabled.
}
High: {
- Label: High
+ Label: Enabled + Slices
Tooltip:
'''
- Enable Tile Texture Soft Blending.
- [c/F05A5A:Allows Sliced Rendering. Not recommended for low-end devices.]
+ Tile texture soft blending is enabled and uses sliced rendering.
+ [c/F05A5A:Not recommended for low-end devices.]
'''
}
}
diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson
index b50e52c512..905840cb08 100644
--- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson
+++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson
@@ -65,11 +65,6 @@ AntiMaterielRifle: {
'''
}
-AquashardShotgun: {
- DisplayName: Aquashard Shotgun
- Tooltip: Converts musket balls into aquashards that split upon hitting an enemy
-}
-
Arbalest: {
DisplayName: Arbalest
Tooltip:
@@ -1109,6 +1104,18 @@ Shadethrower: {
'''
}
+Shardshocker: {
+ DisplayName: Shardshocker
+ Tooltip:
+ '''
+ Fires an electrically charged crystal that travels a short distance before stopping
+ The crystal will hang in the air and occasionally give off damaging pulses of electricity
+ Hitting a stopped crystal with a moving one will detonate both in a massive explosion that lets off homing shards
+ Direct hits with the crystal will create a smaller explosion and stun enemies
+ 'Plasmaaaaaa!'
+ '''
+}
+
Shellshooter: {
DisplayName: Shellshooter
Tooltip:
@@ -1331,6 +1338,15 @@ TheBallista: {
Tooltip: Converts wooden arrows into greatarrows that crush enemy armor and break into shards
}
+TheBlunderbass: {
+ DisplayName: The Blunderbass
+ Tooltip:
+ '''
+ Fires a large crystal that travels a short distance before bursting into homing shards
+ Direct hits with the crystal stun enemies and increase the amount of shards created
+ '''
+}
+
TheHive: {
DisplayName: The Hive
Tooltip:
diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson
index 27cc5aaaef..200dfc4787 100644
--- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson
+++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson
@@ -6,7 +6,7 @@ AngelicBeam.DisplayName: Angelic Beam
AnimosityBullet.DisplayName: Brimstone Round
AquaBlast.DisplayName: Aqua Blast
AquaBlastToxic.DisplayName: Aqua Blast Toxic
-Aquashard.DisplayName: Aquashard
+Aquashard.DisplayName: Aqua Crystal
AquashardSplit.DisplayName: Aquashard
ArcherfishRing.DisplayName: Archerfish Ring
ArcherfishShot.DisplayName: Water Round
@@ -202,6 +202,7 @@ SevensStrikerGrape.DisplayName: Grapes
SevensStrikerOrange.DisplayName: Orange
SevensStrikerPlatinumCoin.DisplayName: Platinum Coin
ShadeFire.DisplayName: Shady Fire
+ShardshockerCrystal.DisplayName: Charged Aqua Crystal
Shell.DisplayName: Shell
Shockblast.DisplayName: Blast
ShockblastRound.DisplayName: Round
diff --git a/NPCs/CalamityDrawParameterNPC.cs b/NPCs/CalamityDrawParameterNPC.cs
index 72699e2f97..91fd106261 100644
--- a/NPCs/CalamityDrawParameterNPC.cs
+++ b/NPCs/CalamityDrawParameterNPC.cs
@@ -109,7 +109,7 @@ namespace CalamityMod.NPCs
return false;
// Safety check for weird MP bug when getting global npcs.
- if (!npc.TryGetGlobalNPCSafer(out var calNPC) || !npc.TryGetGlobalNPCSafer(out var polNPC))
+ if (!npc.TryGetGlobalNPC(out var calNPC) || !npc.TryGetGlobalNPC(out var polNPC))
return false;
// Do not draw if the npc does not have miracle blight, or has the polarity effect.
@@ -131,7 +131,7 @@ namespace CalamityMod.NPCs
return false;
// Safety check for weird MP bug when getting global npcs.
- if (!npc.TryGetGlobalNPCSafer(out var calNPC) || !npc.TryGetGlobalNPCSafer(out var polNPC))
+ if (!npc.TryGetGlobalNPC(out var calNPC) || !npc.TryGetGlobalNPC(out var polNPC))
return false;
// I don't know who would be using this while also inflicting miracle blight, but in that rare case, do not draw these.
diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs
index 59784bca28..ae4cccc19a 100644
--- a/NPCs/CalamityGlobalNPC.cs
+++ b/NPCs/CalamityGlobalNPC.cs
@@ -210,12 +210,6 @@ namespace CalamityMod.NPCs
///
private const float BossZenDistance = 6400f;
- ///
- /// Destroyer laser colors, used for telegraphs.
- /// None = -1, Red = 0, Green = 1, Cyan = 2
- ///
- public int destroyerLaserColor = -1;
-
/// Constant multiplier used to decrease the health and/or damage of pre-Hardmode Desert enemies.
private const double DesertEnemyStatMultiplier = 0.75;
@@ -532,8 +526,6 @@ namespace CalamityMod.NPCs
myClone.miscDefenseLoss = miscDefenseLoss;
- myClone.destroyerLaserColor = destroyerLaserColor;
-
myClone.dashImmunityTime = new int[maxPlayerImmunities];
for (int i = 0; i < maxPlayerImmunities; ++i)
myClone.dashImmunityTime[i] = dashImmunityTime[i];
@@ -5729,28 +5721,25 @@ namespace CalamityMod.NPCs
// Telegraph for body lasers
float telegraphProgress = 0f;
- if (destroyerLaserColor != -1)
+ if (npc.TryGetAIOverride(out var destroyerAI) && destroyerAI.LaserColor != -1)
{
- if (npc.type == NPCID.TheDestroyerBody && revenge)
+ float shootProjectileTime = death ? (phase5 ? 180f : phase4 ? 270f : 360f) : 450f;
+ float telegraphGateValue = shootProjectileTime - DestroyerAI.LaserTelegraphTime;
+ if (newAI[0] > telegraphGateValue)
{
- float shootProjectileTime = death ? (phase5 ? 180f : phase4 ? 270f : 360f) : 450f;
- float telegraphGateValue = shootProjectileTime - DestroyerAI.LaserTelegraphTime;
- if (newAI[0] > telegraphGateValue)
+ switch (destroyerAI.LaserColor)
{
- switch (destroyerLaserColor)
- {
- default:
- case 0:
- break;
- case 1:
- telegraphColor = telegraphColor_Green;
- break;
- case 2:
- telegraphColor = telegraphColor_Cyan;
- break;
- }
- telegraphProgress = MathHelper.Clamp((newAI[0] - telegraphGateValue) / DestroyerAI.LaserTelegraphTime, 0f, 1f);
+ default:
+ case 0:
+ break;
+ case 1:
+ telegraphColor = telegraphColor_Green;
+ break;
+ case 2:
+ telegraphColor = telegraphColor_Cyan;
+ break;
}
+ telegraphProgress = MathHelper.Clamp((newAI[0] - telegraphGateValue) / DestroyerAI.LaserTelegraphTime, 0f, 1f);
}
}
diff --git a/NPCs/CalamityVanillaAIOverrideNPC.cs b/NPCs/CalamityVanillaAIOverrideNPC.cs
index e7bd9d6354..d0c53b0f67 100644
--- a/NPCs/CalamityVanillaAIOverrideNPC.cs
+++ b/NPCs/CalamityVanillaAIOverrideNPC.cs
@@ -26,6 +26,24 @@ using static Terraria.ModLoader.ModContent;
namespace CalamityMod.NPCs;
+public static class VanillaAIOverrideExtension
+{
+ extension(NPC npc)
+ {
+ public bool TryGetAIOverride(out AI aiInstance) where AI : VanillaAIOverride, new()
+ {
+ if (!npc.TryGetGlobalNPC(out var aiOverrideNPC))
+ {
+ aiInstance = null;
+ return false;
+ }
+
+ aiInstance = aiOverrideNPC.AIOverride as AI;
+ return aiInstance != null;
+ }
+ }
+}
+
public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC
{
///
@@ -920,6 +938,11 @@ public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC
return base.PreDraw(npc, spriteBatch, screenPos, drawColor);
}
+ public override void PostDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
+ {
+ AIOverride?.PostDraw(Mod, spriteBatch, screenPos, drawColor);
+ }
+
#endregion
#region Networking
diff --git a/NPCs/Leviathan/Anahita.cs b/NPCs/Leviathan/Anahita.cs
index abfd453e40..c07457543b 100644
--- a/NPCs/Leviathan/Anahita.cs
+++ b/NPCs/Leviathan/Anahita.cs
@@ -446,6 +446,9 @@ namespace CalamityMod.NPCs.Leviathan
NPC.rotation = NPC.velocity.X * 0.02f;
NPC.spriteDirection = NPC.direction;
+ // Remove projectile telegraph
+ DrawProjectileTelegraphTimer = 0;
+
Vector2 anahitaPos = NPC.Center;
float playerXDist = player.position.X + (player.width / 2) - anahitaPos.X;
float playerYDist = player.position.Y + (player.height / 2) - 200f * NPC.scale - anahitaPos.Y;
@@ -788,12 +791,8 @@ namespace CalamityMod.NPCs.Leviathan
NPC.spriteDirection = NPC.direction;
}
- float phaseTimer = 300f;
- phaseTimer -= 50f * enrageScale;
- if (!leviAlive || phase4)
- phaseTimer -= 150f * (1f - lifeRatio);
-
- if (NPC.ai[1] >= phaseTimer)
+ // End behavior after attacking twice
+ if (NPC.ai[1] > attackDivisor * 2)
{
NPC.ai[0] = -1f;
NPC.ai[1] = 2f;
diff --git a/NPCs/Ravager/FlamePillar.cs b/NPCs/Ravager/FlamePillar.cs
index 69962e5cf5..8a7abc4e6c 100644
--- a/NPCs/Ravager/FlamePillar.cs
+++ b/NPCs/Ravager/FlamePillar.cs
@@ -20,6 +20,7 @@ namespace CalamityMod.NPCs.Ravager
public override void SetStaticDefaults()
{
this.HideFromBestiary();
+ NPCID.Sets.ImmuneToAllBuffs[Type] = true;
Main.npcFrameCount[Type] = 4;
if (!Main.dedServ)
{
@@ -35,10 +36,8 @@ namespace CalamityMod.NPCs.Ravager
NPC.damage = 75; // 150
NPC.width = 40;
NPC.height = 150;
- NPC.defense = 35;
- NPC.DR_NERD(0.2f);
NPC.chaseable = false;
- NPC.lifeMax = DownedBossSystem.downedProvidence ? 14000 : 3500;
+ NPC.lifeMax = 1250;
NPC.alpha = 255;
NPC.aiStyle = -1;
AIType = -1;
@@ -59,6 +58,10 @@ namespace CalamityMod.NPCs.Ravager
public override void AI()
{
+ if (NPC.lifeMax > 1250)
+ NPC.lifeMax = 1250;
+ if (NPC.life > NPC.lifeMax)
+ NPC.life = NPC.lifeMax;
// Avoid cheap bullshit
NPC.damage = 0;
@@ -121,6 +124,7 @@ namespace CalamityMod.NPCs.Ravager
}
Vector2 velocity = new Vector2(speedX, speedY);
int type = ModContent.ProjectileType();
+ NPC.SimpleStrikeNPC(NPC.lifeMax/4,0,false,noPlayerInteraction:true);
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, FlameDamage + (provy ? PostProviFlameBuff : 0), 0f, Main.myPlayer, 0f, 0f);
}
@@ -213,5 +217,40 @@ namespace CalamityMod.NPCs.Ravager
}
}
}
+
+ public override void ModifyHitByItem(Player player, Item item, ref NPC.HitModifiers modifiers)
+ {
+ if (item.pick > 0)
+ {
+ modifiers.FlatBonusDamage += -10000;
+ modifiers.FinalDamage.Flat += item.pick - 1;
+ modifiers.SetCrit();
+ }
+ else
+ {
+ modifiers.SetMaxDamage(1);
+ modifiers.DisableCrit();
+ modifiers.HideCombatText();
+ }
+ base.ModifyHitByItem(player, item, ref modifiers);
+ }
+
+ public override void ModifyHitByProjectile(Projectile projectile, ref NPC.HitModifiers modifiers)
+ {
+ var item = Main.player[projectile.owner].HeldItem;
+ if (item.pick > 0 && projectile.CountsAsClass())
+ {
+ modifiers.FlatBonusDamage += -10000;
+ modifiers.FinalDamage.Flat += item.pick-1;
+ modifiers.SetCrit();
+ }
+ else
+ {
+ modifiers.SetMaxDamage(1);
+ modifiers.DisableCrit();
+ modifiers.HideCombatText();
+ }
+ base.ModifyHitByProjectile(projectile, ref modifiers);
+ }
}
}
diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs
index db28bb704f..980dfb4ece 100644
--- a/NPCs/Ravager/RavagerBody.cs
+++ b/NPCs/Ravager/RavagerBody.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using System.Linq;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Events;
using CalamityMod.Items.Accessories;
@@ -507,7 +508,7 @@ namespace CalamityMod.NPCs.Ravager
player = Main.player[NPC.target];
bool shouldFall = player.position.Y >= NPC.Bottom.Y;
- float velocityXBoost = !anyHeadActive ? 6f : death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio);
+ float velocityXBoost = !anyHeadActive ? 6f : 4f * (1f - lifeRatio);
float velocityX = 4f + velocityXBoost;
if (velocityY != 16)
@@ -540,13 +541,13 @@ namespace CalamityMod.NPCs.Ravager
{
velocityX *= 2f;
if (!shouldFall)
- velocityY *= 0.5f;
+ velocityY *= 0.75f;
}
else if (calamityGlobalNPC.newAI[0] % 2f == 0f)
{
velocityX *= 1.5f;
if (!shouldFall)
- velocityY *= 0.75f;
+ velocityY *= 1f;
}
}
@@ -584,7 +585,7 @@ namespace CalamityMod.NPCs.Ravager
if (Main.netMode != NetmodeID.MultiplayerClient)
{
- bool anyRockPillars = NPC.AnyNPCs(ModContent.NPCType());
+ bool anyRockPillars = Main.npc.Any(x => x.active && x.type == ModContent.NPCType() && x.ai[1] < 2);
bool anyFlamePillars = NPC.AnyNPCs(ModContent.NPCType());
if (expertMode)
@@ -593,24 +594,35 @@ namespace CalamityMod.NPCs.Ravager
{
if (n.type == ModContent.NPCType() && n.ai[0] == 0f)
{
- n.ai[1] = -1f;
+ n.ai[1]++;
n.direction = NPC.direction;
n.netUpdate = true;
}
}
int spawnDistance = 360;
+ SoundEngine.PlaySound(PillarSound, NPC.Center);
+ if (death && phase2)
+ {
+ spawnDistance = 300;
+ var index = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X), (int)player.Center.Y - spawnDistance - 100, ModContent.NPCType());
+ if (Main.npc.IndexInRange(index))
+ {
+ var npc = Main.npc[index];
+ (int, int) H_W = (npc.height, npc.width);
+ npc.position = npc.Center;
+ npc.height = H_W.Item2;
+ npc.width = H_W.Item1;
+ npc.rotation = -MathHelper.PiOver2;
+ npc.Center = npc.position;
+ npc.ModNPC.DrawOffsetY = npc.width / 2 - npc.height / 2;
- if (!anyRockPillars || !anyFlamePillars)
- {
- SoundEngine.PlaySound(PillarSound, NPC.Center);
+ }
}
- if (!anyRockPillars || Main.getGoodWorld)
- {
- NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X - spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType());
- NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X + spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType());
- }
- else if (!anyFlamePillars || Main.getGoodWorld)
+ NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X - spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType());
+ NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X + spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType());
+
+ if (!anyFlamePillars && !phase2)
{
float distanceMultiplier = finalPhase ? 2.5f : 2f;
NPC.NewNPC(NPC.GetSource_FromAI(), (int)player.Center.X - (int)(spawnDistance * distanceMultiplier), (int)player.Center.Y - 100, ModContent.NPCType());
@@ -681,7 +693,7 @@ namespace CalamityMod.NPCs.Ravager
else
calamityGlobalNPC.newAI[2] = player.direction;
- float maxOffsetScale = death ? 320f : 240f;
+ float maxOffsetScale = 240f;
float maxOffset = maxOffsetScale * (1f - lifeRatio);
float offset = phase2 ? maxOffset * calamityGlobalNPC.newAI[2] : 0f;
int quarterWidth = (int)(NPC.width * 0.25f);
@@ -723,7 +735,7 @@ namespace CalamityMod.NPCs.Ravager
if (NPC.Bottom.Y < player.position.Y)
{
- float fallSpeedBoost = !anyHeadActive ? 0.9f : death ? 0.9f * (1f - lifeRatio) : 0.6f * (1f - lifeRatio);
+ float fallSpeedBoost = !anyHeadActive ? 0.9f : 0.6f * (1f - lifeRatio);
float fallSpeed = 0.6f + fallSpeedBoost;
if (calamityGlobalNPC.newAI[1] > 1f)
@@ -738,7 +750,7 @@ namespace CalamityMod.NPCs.Ravager
float velocityMult = 1.8f;
float velocityXChange = 0.2f + Math.Abs(NPC.Center.X - player.Center.X) * 0.001f;
- float velocityXBoost = !anyHeadActive ? 6f : death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio);
+ float velocityXBoost = !anyHeadActive ? 6f : 4f * (1f - lifeRatio);
float velocityXCap = 8f + velocityXBoost + Math.Abs(NPC.Center.X - player.Center.X) * 0.001f;
if (!rightClawActive)
diff --git a/NPCs/Ravager/RavagerClawLeft.cs b/NPCs/Ravager/RavagerClawLeft.cs
index 6c330c0b16..dc4ac07a20 100644
--- a/NPCs/Ravager/RavagerClawLeft.cs
+++ b/NPCs/Ravager/RavagerClawLeft.cs
@@ -62,7 +62,6 @@ namespace CalamityMod.NPCs.Ravager
return;
}
- bool death = CalamityWorld.death || BossRushEvent.BossRushActive;
if (NPC.timeLeft < 1800)
{
NPC.timeLeft = 1800;
@@ -93,17 +92,17 @@ namespace CalamityMod.NPCs.Ravager
NPC.rotation = 0f;
NPC.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(-120f, 50f);
NPC.ai[1] += 1f;
- if (NPC.life < NPC.lifeMax / 2 || death)
+ if (NPC.life < NPC.lifeMax / 2)
{
NPC.ai[1] += 1f;
}
- if (NPC.life < NPC.lifeMax / 3 || death)
+ if (NPC.life < NPC.lifeMax / 3)
{
NPC.ai[1] += 1f;
}
- if (NPC.life < NPC.lifeMax / 5 || death)
+ if (NPC.life < NPC.lifeMax / 5)
{
- NPC.ai[1] += 5f;
+ NPC.ai[1] += 2f;
}
if (NPC.ai[1] >= 60f)
{
@@ -143,17 +142,17 @@ namespace CalamityMod.NPCs.Ravager
NPC.collideX = false;
NPC.collideY = false;
float clawSpeed = 12f;
- if (NPC.life < NPC.lifeMax / 2 || death)
+ if (NPC.life < NPC.lifeMax / 2)
{
clawSpeed += 2f;
}
- if (NPC.life < NPC.lifeMax / 3 || death)
+ if (NPC.life < NPC.lifeMax / 3)
{
clawSpeed += 2f;
}
- if (NPC.life < NPC.lifeMax / 5 || death)
+ if (NPC.life < NPC.lifeMax / 5)
{
- clawSpeed += 5f;
+ clawSpeed += 4f;
}
Vector2 npcCenterAttack = new Vector2(NPC.Center.X, NPC.Center.Y);
float targetX = Main.player[NPC.target].Center.X - npcCenterAttack.X;
@@ -200,7 +199,7 @@ namespace CalamityMod.NPCs.Ravager
bodyReturnYDist += 40f;
bodyReturnXDist -= 110f;
float bodyReturnDistance = (float)Math.Sqrt(bodyReturnXDist * bodyReturnXDist + bodyReturnYDist * bodyReturnYDist);
- if ((bodyReturnDistance > (death ? 900f : 700f) || NPC.collideX || NPC.collideY) | NPC.justHit)
+ if ((bodyReturnDistance > 700f || NPC.collideX || NPC.collideY) | NPC.justHit)
{
// Avoid cheap bullshit
NPC.damage = 0;
diff --git a/NPCs/Ravager/RavagerClawRight.cs b/NPCs/Ravager/RavagerClawRight.cs
index 0e9178538e..8a0426db9e 100644
--- a/NPCs/Ravager/RavagerClawRight.cs
+++ b/NPCs/Ravager/RavagerClawRight.cs
@@ -62,7 +62,6 @@ namespace CalamityMod.NPCs.Ravager
return;
}
- bool death = CalamityWorld.death || BossRushEvent.BossRushActive;
if (NPC.timeLeft < 1800)
{
NPC.timeLeft = 1800;
@@ -93,17 +92,17 @@ namespace CalamityMod.NPCs.Ravager
NPC.rotation = 0f;
NPC.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(120f, 50f);
NPC.ai[1] += 1f;
- if (NPC.life < NPC.lifeMax / 2 || death)
+ if (NPC.life < NPC.lifeMax / 2)
{
NPC.ai[1] += 1f;
}
- if (NPC.life < NPC.lifeMax / 3 || death)
+ if (NPC.life < NPC.lifeMax / 3)
{
NPC.ai[1] += 1f;
}
- if (NPC.life < NPC.lifeMax / 5 || death)
+ if (NPC.life < NPC.lifeMax / 5)
{
- NPC.ai[1] += 5f;
+ NPC.ai[1] += 2f;
}
if (NPC.ai[1] >= 60f)
{
@@ -143,17 +142,17 @@ namespace CalamityMod.NPCs.Ravager
NPC.collideX = false;
NPC.collideY = false;
float clawSpeed = 12f;
- if (NPC.life < NPC.lifeMax / 2 || death)
+ if (NPC.life < NPC.lifeMax / 2)
{
clawSpeed += 2f;
}
- if (NPC.life < NPC.lifeMax / 3 || death)
+ if (NPC.life < NPC.lifeMax / 3)
{
clawSpeed += 2f;
}
- if (NPC.life < NPC.lifeMax / 5 || death)
+ if (NPC.life < NPC.lifeMax / 5)
{
- clawSpeed += 5f;
+ clawSpeed += 4f;
}
Vector2 npcCenterAttack = new Vector2(NPC.Center.X, NPC.Center.Y);
float targetX = Main.player[NPC.target].Center.X - npcCenterAttack.X;
@@ -200,7 +199,7 @@ namespace CalamityMod.NPCs.Ravager
bodyReturnYDist += 40f;
bodyReturnXDist += 110f;
float bodyReturnDistance = (float)Math.Sqrt(bodyReturnXDist * bodyReturnXDist + bodyReturnYDist * bodyReturnYDist);
- if ((bodyReturnDistance > (death ? 900f : 700f) || NPC.collideX || NPC.collideY) | NPC.justHit)
+ if ((bodyReturnDistance > 700f || NPC.collideX || NPC.collideY) | NPC.justHit)
{
// Avoid cheap bullshit
NPC.damage = 0;
diff --git a/NPCs/Ravager/RavagerHead2.cs b/NPCs/Ravager/RavagerHead2.cs
index b7c57c63bf..b1754dfac9 100644
--- a/NPCs/Ravager/RavagerHead2.cs
+++ b/NPCs/Ravager/RavagerHead2.cs
@@ -50,6 +50,7 @@ namespace CalamityMod.NPCs.Ravager
}
NPC.Calamity().VulnerableToSickness = false;
NPC.Calamity().VulnerableToWater = true;
+ NPC.dontTakeDamage = true;
}
public override void AI()
@@ -123,17 +124,6 @@ namespace CalamityMod.NPCs.Ravager
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity * 0.25f, type, RavagerHead.NukeDamage + (provy ? RavagerHead.PostProviNukeBuff : 0), 0f, Main.myPlayer, Main.npc[CalamityGlobalNPC.scavenger].target, 0f);
}
}
- else
- {
- if (NPC.ai[1] % 40f == 0f)
- {
- if (Main.netMode != NetmodeID.MultiplayerClient)
- {
- SoundEngine.PlaySound(SoundID.Item33, NPC.Center);
- Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity, type, HomingDartDamage + (provy ? PostProviDartBuff : 0), 0f, Main.myPlayer, 0f, -1f);
- }
- }
- }
}
float attackMovementVel = 22f;
diff --git a/NPCs/Ravager/RockPillar.cs b/NPCs/Ravager/RockPillar.cs
index 5ad924bdf8..ad80d16cc6 100644
--- a/NPCs/Ravager/RockPillar.cs
+++ b/NPCs/Ravager/RockPillar.cs
@@ -14,6 +14,7 @@ namespace CalamityMod.NPCs.Ravager
public override void SetStaticDefaults()
{
this.HideFromBestiary();
+ NPCID.Sets.ImmuneToAllBuffs[Type] = true;
}
public override void SetDefaults()
@@ -25,7 +26,6 @@ namespace CalamityMod.NPCs.Ravager
NPC.defense = 50;
NPC.DR_NERD(0.3f);
NPC.chaseable = false;
- NPC.lifeMax = DownedBossSystem.downedProvidence ? 20000 : 5000;
NPC.alpha = 255;
NPC.aiStyle = -1;
AIType = -1;
@@ -34,10 +34,23 @@ namespace CalamityMod.NPCs.Ravager
NPC.DeathSound = SoundID.NPCDeath14;
NPC.Calamity().VulnerableToSickness = false;
NPC.Calamity().VulnerableToWater = true;
+ NPCID.Sets.ImmuneToAllBuffs[Type] = true;
+ NPC.lifeMax = 1800;
}
+ //Disable dmg when stationary vertically or before jumping
+ public override bool CanHitPlayer(Player target, ref int cooldownSlot)
+ {
+ if (NPC.velocity.Y == 0 || NPC.ai[0] == 0f)
+ return false;
+ return base.CanHitPlayer(target, ref cooldownSlot);
+ }
public override void AI()
{
+ if (NPC.lifeMax > 1800)
+ NPC.lifeMax = 1800;
+ if (NPC.life > NPC.lifeMax)
+ NPC.life = NPC.lifeMax;
if (CalamityGlobalNPC.scavenger < 0 || !Main.npc[CalamityGlobalNPC.scavenger].active)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
@@ -60,17 +73,13 @@ namespace CalamityMod.NPCs.Ravager
}
else
{
- if (DownedBossSystem.downedProvidence && !BossRushEvent.BossRushActive)
- NPC.damage = (int)(NPC.defDamage * 1.5);
- else
- NPC.damage = NPC.defDamage;
}
- if (NPC.ai[0] == 0f)
+ if (NPC.ai[0] == 0)
{
if (NPC.velocity.Y == 0f)
{
- if (NPC.ai[1] == -1f)
+ if (NPC.ai[1] >= 2)
{
SoundEngine.PlaySound(SoundID.Item62, NPC.Center);
@@ -94,10 +103,14 @@ namespace CalamityMod.NPCs.Ravager
}
NPC.noTileCollide = true;
- NPC.velocity.X = 12 * NPC.direction;
+ if (NPC.rotation == 0)
+ NPC.velocity.X = 12 * NPC.direction;
NPC.velocity.Y = -28.5f;
NPC.ai[0] = 1f;
- NPC.ai[1] = 0f;
+ NPC.ai[1] = 0;
+ NPC.damage = NPC.defDamage;
+ if (DownedBossSystem.downedProvidence && !BossRushEvent.BossRushActive)
+ NPC.damage = (int)(NPC.defDamage * 1.5);
}
}
}
@@ -122,7 +135,7 @@ namespace CalamityMod.NPCs.Ravager
}
}
}
- public override bool? CanFallThroughPlatforms() => NPC.target >= 0 && Main.player[NPC.target].position.Y > NPC.position.Y + NPC.height;
+ public override bool? CanFallThroughPlatforms() => NPC.ai[0] != 0 || ((NPC.alpha > 10) || (NPC.target >= 0 && Main.player[NPC.target].position.Y > NPC.position.Y + NPC.height));
public override bool CheckActive() => false;
public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo)
@@ -205,5 +218,40 @@ namespace CalamityMod.NPCs.Ravager
}
}
}
+
+ public override void ModifyHitByItem(Player player, Item item, ref NPC.HitModifiers modifiers)
+ {
+ if (item.pick > 0)
+ {
+ modifiers.FlatBonusDamage += -10000;
+ modifiers.FinalDamage.Flat += item.pick - 1;
+ modifiers.SetCrit();
+ }
+ else
+ {
+ modifiers.SetMaxDamage(1);
+ modifiers.DisableCrit();
+ modifiers.HideCombatText();
+ }
+ base.ModifyHitByItem(player, item, ref modifiers);
+ }
+
+ public override void ModifyHitByProjectile(Projectile projectile, ref NPC.HitModifiers modifiers)
+ {
+ var item = Main.player[projectile.owner].HeldItem;
+ if (item.pick > 0 && projectile.CountsAsClass())
+ {
+ modifiers.FlatBonusDamage += -10000;
+ modifiers.FinalDamage.Flat += item.pick - 1;
+ modifiers.SetCrit();
+ }
+ else
+ {
+ modifiers.SetMaxDamage(1);
+ modifiers.DisableCrit();
+ modifiers.HideCombatText();
+ }
+ base.ModifyHitByProjectile(projectile, ref modifiers);
+ }
}
}
diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs
index ca70a4de96..ad778bbd19 100644
--- a/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs
+++ b/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs
@@ -16,7 +16,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
// Vanilla values
public static int CloneFireballDamage = 18; // 72
public static int FireballDamage = 20; // 80
- public static int IceMistDamage = 25; // 100
+ public static int IceMistDamage = 1; // This attack never actually hits, so damage number is irrelevant
public static int LightningDamage = 30; // 120
public static int DoomDamage = 45; // 180 (Also fixes Master Mode scaling)
@@ -64,16 +64,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
int lightningDamage = isCultist ? LightningDamage : 0;
int iceMistFireRate = phase2 ? 50 : 60;
- float iceMistSpeed = (phase6 ? 12f : 10f) + (death ? (1f - lifeRatio) : 0f);
+ float iceMistSpeed = 12f + (death ? 4f : 2f) * (1f - lifeRatio);
int iceMistAmt = phase3 ? 2 : 1;
- int fireballFireRate = (phase5 ? 10 : 12) - (death ? 6 : 0);
+ int fireballFireRate = (phase5 ? 20 : 24) - (death ? 5 : 0);
float fireballSpeed = ((phase7 ? 8f : phase6 ? 7f : 6f) + (death ? (1f - lifeRatio) : 0f)) * (isCultist ? 1f : 0.5f);
- int fireballAmt = death ? 20 : 4;
+ int fireballAmt = death ? 8 : 4;
int lightningOrbPhaseTime = phase2 ? 90 : 120;
int ancientLightSpawnRate = phase7 ? 20 : phase4 ? 25 : 30;
int ancientLightAmt = phase7 ? 4 : phase4 ? 3 : 2;
int ancientDoomLimit = 10;
- int idleTime = phase8 ? 20 : phase7 ? 30 : phase3 ? 35 : 40;
+ int idleTime = phase8 ? 40 : phase7 ? 45 : phase3 ? 55 : 60;
float timeToFinishRitual = phase8 ? 180f : phase7 ? 240f : phase5 ? 300f : 360f;
if (Main.getGoodWorld)
@@ -135,6 +135,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
NPC.ai[0] = Main.npc[(int)NPC.ai[3]].ai[0];
NPC.ai[1] = Main.npc[(int)NPC.ai[3]].ai[1];
dontTakeDamage = true;
+
+ if (NPC.ai[0] == 5f && NPC.ai[1] >= 120f && NPC.ai[1] < timeToFinishRitual)
+ {
+ dontTakeDamage = false;
+ if (NPC.justHit)
+ {
+ var mainCultist = Main.npc[(int)NPC.ai[3]];
+ mainCultist.ai[1] = timeToFinishRitual;
+ }
+ }
}
// Stop spawning ritual if hit
@@ -152,6 +162,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
NPC.netUpdate = true;
Main.projectile[(int)NPC.ai[2]].ai[1] = -1f;
Main.projectile[(int)NPC.ai[2]].netUpdate = true;
+
+ foreach (var item in Main.ActiveNPCs)
+ {
+ if (item.type == NPCID.CultistBossClone && item.ai[3] == NPC.whoAmI)
+ {
+ item.active = false;
+ item.ForceNetUpdate();
+ }
+ }
}
// Despawn
@@ -257,11 +276,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
{
// Move to target
case 0:
- case 2:
case 4:
case 6:
case 8:
- case 10:
case 12:
case 14:
case 16:
@@ -270,6 +287,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
phase = 0;
break;
+ case 2:
+ case 10:
+ phase = 0;
+ distanceAboveTarget *= 1.5f;
+ predictionDistance *= 1.5f;
+ break;
// Fireball
case 1:
case 15:
@@ -470,7 +493,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
Vector2 iceMistDirection = NPC.Center + new Vector2(NPC.direction * 30, 12f);
Vector2 iceMistVelocity = vec * iceMistSpeed;
- Projectile.NewProjectile(NPC.GetSource_FromAI(), iceMistDirection, iceMistVelocity, ProjectileID.CultistBossIceMist, iceMistDamage, 0f, Main.myPlayer, 0f, 1f);
+ var icemist = Main.projectile[Projectile.NewProjectile(NPC.GetSource_FromAI(), iceMistDirection, iceMistVelocity, ProjectileID.CultistBossIceMist, iceMistDamage, 0f, Main.myPlayer, 0f, 1f)];
+ icemist.timeLeft = 240;
}
}
@@ -534,14 +558,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
if (Main.netMode != NetmodeID.MultiplayerClient)
{
- playerDirection = Vector2.Normalize(player.Center - NPC.Center);
+ playerDirection = NPC.DirectionTo(player.Center);
if (playerDirection.HasNaNs())
playerDirection = new Vector2(NPC.direction, 0f);
Vector2 fireballDirection = NPC.Center + new Vector2(NPC.direction * 30, 12f);
Vector2 fireballVelocity = playerDirection * (fireballSpeed + (float)Main.rand.NextDouble() * 2f);
fireballVelocity = fireballVelocity.RotatedByRandom(Math.PI / 6D);
- Projectile.NewProjectile(NPC.GetSource_FromAI(), fireballDirection, fireballVelocity, ProjectileID.CultistBossFireBall, fireballDamage, 0f, Main.myPlayer);
+ for (var i = -1; i <= 1; i++)
+ Projectile.NewProjectile(NPC.GetSource_FromAI(), fireballDirection, fireballVelocity.RotatedBy(1f * i), ProjectileID.CultistBossFireBall, fireballDamage, 0f, Main.myPlayer);
}
}
@@ -639,10 +664,20 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
if (Main.npc[k].active && Main.npc[k].type == NPCID.CultistBossClone && Main.npc[k].ai[3] == NPC.whoAmI)
list6.Add(k);
}
-
- int potentialExtraClones = 6 - list6.Count;
- if (potentialExtraClones > 2)
- potentialExtraClones = 2;
+ int maxClonesSpawned = 2;
+ if (death)
+ maxClonesSpawned += 2;
+ if (lifeRatio < 0.75f)
+ maxClonesSpawned++;
+ if (lifeRatio < 0.5f)
+ maxClonesSpawned++;
+ if (lifeRatio < 0.25f)
+ maxClonesSpawned++;
+ if (lifeRatio < 0.1f)
+ maxClonesSpawned++;
+ int potentialExtraClones = 8 - list6.Count;
+ if (potentialExtraClones > maxClonesSpawned)
+ potentialExtraClones = maxClonesSpawned;
int newCloneAmt = list6.Count + potentialExtraClones + 1;
float[] array = new float[newCloneAmt];
@@ -826,7 +861,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
if (playerDirection.HasNaNs())
playerDirection = new Vector2(NPC.direction, 0f);
- if ((NPC.ai[1] >= 4f & isCultist) && (int)(NPC.ai[1] - 4f) % ancientLightSpawnRate == 0)
+ if ((NPC.ai[1] >= 4f & isCultist) && (int)(NPC.ai[1] - 4f) % ancientLightSpawnRate == 0 && (int)(NPC.ai[1] - 4f) / ancientLightSpawnRate <= (death ? 4 : 3))
{
if ((int)(NPC.ai[1] - 4f) / ancientLightSpawnRate == 2)
{
@@ -858,26 +893,26 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
if (playerDirection.HasNaNs())
playerDirection = new Vector2(NPC.direction, 0f);
- Vector2 ancientLightShootDirection = NPC.Center + new Vector2(NPC.direction * 30, 12f);
- float scaleFactor = death ? 6f : 4f;
+ Vector2 ancientLightShootDirection = NPC.Center;
+ float scaleFactor = death ? 5f : 4f;
- float ancientLightSpread = MathHelper.ToRadians(15f);
- int ancientLightInc = 0;
- float totalAncientLights = 5f;
- while (ancientLightInc < totalAncientLights)
+ float ancientLightSpread = MathHelper.ToRadians(CalamityWorld.death ? 90f : 80f);
+ float totalAncientLights = death ? 9 : 7;
+ float adjustTotal = totalAncientLights - 1;
+ for (var i = 0; i < totalAncientLights; i++)
{
- Vector2 ancientLightSpeed = playerDirection * scaleFactor;
- ancientLightSpeed = ancientLightSpeed.RotatedBy(ancientLightSpread * ancientLightInc - (MathHelper.Pi / totalAncientLights * 2f - ancientLightSpread) / 2f);
- float ai = (Main.rand.NextFloat() - 0.5f) * 0.3f * MathHelper.TwoPi / 60f;
+ var shotgunscalar = Math.Abs(i - (adjustTotal * 0.5f)) / (adjustTotal * 0.5f);
+ float angleOffset = ancientLightSpread * (i / adjustTotal) - ancientLightSpread * 0.5f;
+ Vector2 ancientLightSpeed = playerDirection.RotatedBy(angleOffset) * scaleFactor * (0.75f + 1.5f * shotgunscalar);
+ float ai = (Main.rand.NextFloat() - 0.5f) * 0.2f * MathHelper.TwoPi / 60f;
int ancientLightProj = NPC.NewNPC(NPC.GetSource_FromAI(), (int)ancientLightShootDirection.X, (int)ancientLightShootDirection.Y + 7, NPCID.AncientLight, 0, 0f, ai, ancientLightSpeed.X, ancientLightSpeed.Y);
Main.npc[ancientLightProj].velocity = ancientLightSpeed;
- ancientLightInc++;
}
}
}
NPC.ai[1] += 1f;
- if (NPC.ai[1] >= (4 + ancientLightSpawnRate * ancientLightAmt))
+ if (NPC.ai[1] >= (30 + ancientLightSpawnRate * ancientLightAmt))
{
NPC.ai[0] = 0f;
NPC.ai[1] = 0f;
@@ -892,7 +927,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
{
NPC.localAI[2] = 13f;
- if ((NPC.ai[1] >= 4f & isCultist) && (int)(NPC.ai[1] - 4f) % 20f == 0f)
+ if ((NPC.ai[1] >= 4f & isCultist) && (int)(NPC.ai[1] - 4f) % 20f == 0f && NPC.ai[1] <= 64)
{
List list8 = new List();
for (int k = 0; k < Main.maxNPCs; k++)
@@ -901,9 +936,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
list8.Add(k);
}
- int ancientDoomAmt = list8.Count + 1;
- if (ancientDoomAmt > 2)
- ancientDoomAmt = 2;
+ int ancientDoomAmount = 2;
+ if (lifeRatio < 0.75f && death)
+ ancientDoomAmount++;
+ if (lifeRatio < 0.5f)
+ ancientDoomAmount++;
+ if (lifeRatio < 0.25f && death)
+ ancientDoomAmount++;
int ancientDoomFaceDirection = Math.Sign(player.Center.X - NPC.Center.X);
if (ancientDoomFaceDirection != 0)
@@ -911,56 +950,19 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
if (Main.netMode != NetmodeID.MultiplayerClient)
{
- if (phase4)
- {
// Spawn circle of Ancient Dooms around target
- for (int i = 0; i < ancientDoomLimit; i++)
+ for (int i = 0; i < ancientDoomAmount; i++)
{
- float ai2 = i * 120;
+ float ai2 = i * (360f/ancientDoomAmount);
NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X + (float)(Math.Sin(i * 120) * 550)), (int)(player.Center.Y + (float)(Math.Cos(i * 120) * 550)),
NPCID.AncientDoom, 0, NPC.whoAmI, 0f, ai2, 0f, Main.maxPlayers);
}
- }
- else
- {
- // Spawn Ancient Dooms randomly around the target
- for (int i = 0; i < ancientDoomAmt; i++)
- {
- Point cultistCenterTileCoords = NPC.Center.ToTileCoordinates();
- Point targetCenterTileCoords = Main.player[NPC.target].Center.ToTileCoordinates();
- Vector2 targetDistanceDoom = Main.player[NPC.target].Center - NPC.Center;
- int randSpawnOffset = 20;
- int cultistCenterSpawnOffset = 3;
- int targetCenterSpawnOffset = 7;
- int tileCollisionRange = 2;
- int spawnAttempts = 0;
- bool doomSufficientlyFar = targetDistanceDoom.Length() > 2800f;
- while (!doomSufficientlyFar && spawnAttempts < 100)
- {
- spawnAttempts++;
- int ancientDoomSpawnX = Main.rand.Next(targetCenterTileCoords.X - randSpawnOffset, targetCenterTileCoords.X + randSpawnOffset + 1);
- int ancientDoomSpawnY = Main.rand.Next(targetCenterTileCoords.Y - randSpawnOffset, targetCenterTileCoords.Y + randSpawnOffset + 1);
- if ((ancientDoomSpawnY < targetCenterTileCoords.Y - targetCenterSpawnOffset || ancientDoomSpawnY > targetCenterTileCoords.Y + targetCenterSpawnOffset || ancientDoomSpawnX < targetCenterTileCoords.X - targetCenterSpawnOffset || ancientDoomSpawnX > targetCenterTileCoords.X + targetCenterSpawnOffset) && (ancientDoomSpawnY < cultistCenterTileCoords.Y - cultistCenterSpawnOffset || ancientDoomSpawnY > cultistCenterTileCoords.Y + cultistCenterSpawnOffset || ancientDoomSpawnX < cultistCenterTileCoords.X - cultistCenterSpawnOffset || ancientDoomSpawnX > cultistCenterTileCoords.X + cultistCenterSpawnOffset) && !Main.tile[ancientDoomSpawnX, ancientDoomSpawnY].HasUnactuatedTile)
- {
- bool notInsideTiles = true;
- if (notInsideTiles && Collision.SolidTiles(ancientDoomSpawnX - tileCollisionRange, ancientDoomSpawnX + tileCollisionRange, ancientDoomSpawnY - tileCollisionRange, ancientDoomSpawnY + tileCollisionRange))
- notInsideTiles = false;
-
- if (notInsideTiles)
- {
- NPC.NewNPC(NPC.GetSource_FromAI(), ancientDoomSpawnX * 16 + 8, ancientDoomSpawnY * 16 + 8, NPCID.AncientDoom, 0, NPC.whoAmI);
- break;
- }
- }
- }
- }
- }
}
}
NPC.ai[1] += 1f;
- if (NPC.ai[1] >= 64f)
+ if (NPC.ai[1] >= 195f)
{
NPC.ai[0] = 0f;
NPC.ai[1] = 0f;
@@ -1000,14 +1002,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
NPC.velocity = Vector2.Zero;
NPC.position = NPC.oldPosition;
- // Kill after 4 seconds
- NPC.ai[1] += 1f;
- if (NPC.ai[1] >= 240f)
- {
- NPC.HitEffect(0, 9999.0);
- NPC.active = false;
- }
+ // Kill after half a second
+ NPC.ai[1] += 1f;
+ if (NPC.ai[1] >= 30f)
+ {
+ NPC.HitEffect(0, 9999.0);
+ NPC.active = false;
}
+ }
return false;
}
@@ -1096,7 +1098,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
NPC.damage = NPC.defDamage = 0;
float duration = 420f;
float spawnAnimTime = 120f;
- int rateOfChange = death ? 2 : 1;
+ int rateOfChange = 6;
float splitProjVelocity = death ? 4.5f : 3f;
// Percent life remaining for Cultist or Eidolon Wyrm
@@ -1113,17 +1115,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
if (target == Main.maxPlayers)
target = Main.npc[(int)NPC.ai[0]].target;
- if (phase2 || death)
- rateOfChange++;
-
- if (phase4 || death)
- rateOfChange++;
-
- if (Main.npc[(int)NPC.ai[0]].type == ModContent.NPCType())
+ if (Main.npc[(int)NPC.ai[0]].type == ModContent.NPCType())
NPC.dontTakeDamage = true;
- }
- else
- kill = true;
+ }
+ else
+ kill = true;
NPC.ai[1] += rateOfChange;
float growthRate = NPC.ai[1] / spawnAnimTime;
@@ -1133,25 +1129,22 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
NPC.Center = NPC.position;
NPC.alpha = (int)(255f - growthRate * 255f);
- if (phase3)
- {
- if (NPC.ai[3] == 0f)
- NPC.ai[3] = NPC.ai[2];
+ if (NPC.ai[3] == 0f)
+ NPC.ai[3] = NPC.ai[2];
- double deg = NPC.ai[3];
- double rad = deg * (Math.PI / 180);
- double dist = 550;
- if (Main.npc[(int)NPC.ai[0]].type == ModContent.NPCType())
- {
- float aiGateValue = Main.npc[(int)NPC.ai[0]].Calamity().newAI[2] - 30f;
- int ancientDoomScale = (int)(aiGateValue / 120f);
- dist += ancientDoomScale * 45;
- }
- NPC.position.X = Main.player[target].Center.X - (int)(Math.Cos(rad) * dist) - NPC.width / 2;
- NPC.position.Y = Main.player[target].Center.Y - (int)(Math.Sin(rad) * dist) - NPC.height / 2;
- float spinVelocity = 8f * (1f - (NPC.ai[1] / duration));
- NPC.ai[3] += spinVelocity;
+ double deg = NPC.ai[3];
+ double rad = deg * (Math.PI / 180);
+ double dist = 550;
+ if (Main.npc[(int)NPC.ai[0]].type == ModContent.NPCType())
+ {
+ float aiGateValue = Main.npc[(int)NPC.ai[0]].Calamity().newAI[2] - 30f;
+ int ancientDoomScale = (int)(aiGateValue / 120f);
+ dist += ancientDoomScale * 45;
}
+ NPC.position.X = Main.player[target].Center.X - (int)(Math.Cos(rad) * dist) - NPC.width / 2;
+ NPC.position.Y = Main.player[target].Center.Y - (int)(Math.Sin(rad) * dist) - NPC.height / 2;
+ float spinVelocity = 8f * (1f - (NPC.ai[1] / duration));
+ NPC.ai[3] += spinVelocity;
if (Main.rand.NextBool(6))
{
@@ -1197,19 +1190,21 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
if (Main.npc[(int)NPC.ai[0]].type == ModContent.NPCType())
damage = (int)Math.Round(damage * PrimordialWyrmHead.DoomDamageMult);
- kill = true;
- if (Main.netMode != NetmodeID.MultiplayerClient)
+ kill = true;
+ if (Main.netMode != NetmodeID.MultiplayerClient)
+ {
+ int totalProjectiles = Main.getGoodWorld ? 5 : 3;
+ float radians = MathHelper.TwoPi / totalProjectiles;
+ Vector2 spinningPoint = new Vector2(0f, -splitProjVelocity);
+ var rotOffset = NPC.DirectionTo(Main.player[target].Center).ToRotation();
+ for (int k = 0; k < totalProjectiles; k++)
{
- int totalProjectiles = Main.getGoodWorld ? 9 : (Main.npc[(int)NPC.ai[0]].type == NPCID.CultistBoss && !phase3) ? 8 : death ? 5 : 4;
- float radians = MathHelper.TwoPi / totalProjectiles;
- Vector2 spinningPoint = new Vector2(0f, -splitProjVelocity);
- for (int k = 0; k < totalProjectiles; k++)
- {
- Vector2 doomProjRotate = spinningPoint.RotatedBy(radians * k);
- Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, doomProjRotate, type, damage, 0f, Main.myPlayer);
- }
+ Vector2 doomProjRotate = spinningPoint.RotatedBy(rotOffset + MathHelper.Pi*((k+1)/(float)(totalProjectiles+1)));
+ var proj = Main.projectile[Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, doomProjRotate, type, damage, 0f, Main.myPlayer)];
+ proj.tileCollide = false;
}
}
+ }
if (kill)
{
diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs
index 764116860a..bbfcf11786 100644
--- a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs
+++ b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using CalamityMod.Events;
using CalamityMod.Particles;
using CalamityMod.Projectiles.Boss;
@@ -10,6 +11,7 @@ using Terraria.DataStructures;
using Terraria.Enums;
using Terraria.ID;
using Terraria.ModLoader;
+using Terraria.ModLoader.IO;
namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
{
@@ -37,6 +39,22 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
// Rev+ exclusive
public static int LaserDamage = 25; // 100 (buffed); Applies to all Rev+ lasers
+ ///
+ /// Destroyer laser colors, used for telegraphs.
+ /// None = -1, Red = 0, Green = 1, Cyan = 2
+ ///
+ public sbyte LaserColor = -1;
+
+ public override void SendExtraAI(BitWriter bitWriter, BinaryWriter binaryWriter)
+ {
+ binaryWriter.Write(LaserColor);
+ }
+
+ public override void ReceiveExtraAI(BitReader bitReader, BinaryReader binaryReader)
+ {
+ LaserColor = binaryReader.ReadSByte();
+ }
+
public override bool AI(Mod mod)
{
int mechdusaCurvedSpineSegmentIndex = 0;
@@ -262,33 +280,33 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
// Fire lasers
if (NPC.type == NPCID.TheDestroyerBody)
{
- bool ableToFireLaser = calamityGlobalNPC.destroyerLaserColor != -1;
+ bool ableToFireLaser = LaserColor != -1;
// Set laser color and type
- if (calamityGlobalNPC.destroyerLaserColor == -1 && !probeLaunched)
+ if (LaserColor == -1 && !probeLaunched)
{
int random = phase3 ? 4 : phase2 ? 3 : 2;
switch (Main.rand.Next(random))
{
case 0:
case 1:
- calamityGlobalNPC.destroyerLaserColor = 0;
+ LaserColor = 0;
break;
case 2:
- calamityGlobalNPC.destroyerLaserColor = 1;
+ LaserColor = 1;
break;
case 3:
- calamityGlobalNPC.destroyerLaserColor = 2;
+ LaserColor = 2;
break;
}
- NPC.SyncDestroyerLaserColor();
+ NPC.netUpdate = true;
}
if (probeLaunched && ableToFireLaser)
{
- calamityGlobalNPC.destroyerLaserColor = -1;
- NPC.SyncDestroyerLaserColor();
+ LaserColor = -1;
+ NPC.netUpdate = true;
}
// Laser rate of fire
@@ -304,7 +322,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
}
Color telegraphColor = Color.Transparent;
- switch (calamityGlobalNPC.destroyerLaserColor)
+ switch (LaserColor)
{
case 0:
telegraphColor = Color.Red;
@@ -379,7 +397,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
// Set projectile damage and type
int projectileType = ProjectileID.DeathLaser;
- switch (calamityGlobalNPC.destroyerLaserColor)
+ switch (LaserColor)
{
default:
case 0:
@@ -408,15 +426,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
if (death)
{
- calamityGlobalNPC.destroyerLaserColor = -1;
- NPC.SyncDestroyerLaserColor();
+ LaserColor = -1;
+ NPC.netUpdate = true;
}
}
if (!death)
{
- calamityGlobalNPC.destroyerLaserColor = -1;
- NPC.SyncDestroyerLaserColor();
+ LaserColor = -1;
+ NPC.netUpdate = true;
}
}
}
@@ -515,7 +533,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
// Telegraph for the laser breath and body lasers
float telegraphProgress = 0f;
- if (calamityGlobalNPC.destroyerLaserColor != -1)
+ if (LaserColor != -1)
{
if (NPC.type == NPCID.TheDestroyerBody)
{
@@ -523,7 +541,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses
float telegraphGateValue = shootProjectileTime - LaserTelegraphTime;
if (calamityGlobalNPC.newAI[0] > telegraphGateValue)
{
- switch (calamityGlobalNPC.destroyerLaserColor)
+ switch (LaserColor)
{
default:
case 0:
diff --git a/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs b/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs
index 6b43999d7f..a26c0a6bb0 100644
--- a/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs
+++ b/NPCs/VanillaNPCAIOverrides/VanillaAIOverride.cs
@@ -49,6 +49,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides
public virtual bool PreDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) => true;
+ public virtual void PostDraw(Mod mod, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { }
+
///
/// This Method should be Implemented If we added our custom field to AI Overrides
///
diff --git a/Packets/Entities/VanillaChanges/SyncDestroyerLaserColorPacket.cs b/Packets/Entities/VanillaChanges/SyncDestroyerLaserColorPacket.cs
deleted file mode 100644
index f85088c450..0000000000
--- a/Packets/Entities/VanillaChanges/SyncDestroyerLaserColorPacket.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.IO;
-using Terraria;
-
-namespace CalamityMod.Packets
-{
- internal sealed class SyncDestroyerLaserColorPacket : CalamityPacket
- {
- public static SyncDestroyerLaserColorPacket Instance { get; private set; }
-
- public override byte MessageType => (byte)CalamityModMessageType.SyncDestroyerLaserColor;
-
- public static void Send(NPC npc, int toClient = -1, int ignoreClient = -1)
- {
- if (npc is null)
- return;
-
- var packet = Instance.CreateBasePacket();
- packet.WriteWhoAmI(npc);
- packet.Write(npc.Calamity().destroyerLaserColor);
- packet.Send(toClient, ignoreClient);
- }
-
- public override void HandlePacket(in BinaryReader packet, int sender)
- {
- var npc = packet.ReadNPC();
- var laserColor = packet.ReadInt32();
-
- if (npc is null)
- return;
-
- npc.Calamity().destroyerLaserColor = laserColor;
- }
- }
-}
diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs
index 88bf2c043c..1a10ce3df1 100644
--- a/Particles/GeneralParticleHandler.cs
+++ b/Particles/GeneralParticleHandler.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using CalamityMod.Enums;
+using CalamityMod.Systems.Graphic;
using CalamityMod.Systems.Graphic.PixelationSystem;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -100,6 +101,8 @@ namespace CalamityMod.Particles
particlesToDraw = [];
particlesToDraw_Pixelated = [];
particlesToDraw_CustomShader = [];
+
+ GeneralDrawLayerSystem.OnDrawLayer += DrawParticleCollectionsAtSpecificLayer;
}
public override void Unload()
@@ -289,7 +292,7 @@ namespace CalamityMod.Particles
particlesToKill.Clear();
}
- internal static void DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer drawLayer)
+ private static void DrawParticleCollectionsAtSpecificLayer(GeneralDrawLayer drawLayer)
{
if (Main.dedServ)
return;
diff --git a/Prefixes/ReforgeChange.cs b/Prefixes/ReforgeChange.cs
new file mode 100644
index 0000000000..4930d90c47
--- /dev/null
+++ b/Prefixes/ReforgeChange.cs
@@ -0,0 +1,295 @@
+using System.Linq;
+using CalamityMod.NPCs.TownNPCs;
+using CalamityMod.Packets;
+using CalamityMod.World;
+using Terraria;
+using Terraria.GameContent.Prefixes;
+using Terraria.ID;
+using Terraria.ModLoader;
+using Terraria.Utilities;
+
+using static Terraria.ModLoader.ModContent;
+
+namespace CalamityMod.Prefixes
+{
+ public sealed class ReforgeChange : GlobalItem
+ {
+ public override bool InstancePerEntity => false;
+
+ // Ozzatron 31AUG2022: total rework to the reforge rework for mod compatibility
+ // you can now disable the rework with config in case it isn't enough to solve your conflicts
+ // removed data saved on items; reforging is now a coalescing flowchart that has no RNG
+ public override int ChoosePrefix(Item item, UnifiedRandom rand)
+ {
+ int storedPrefix = item.prefix;
+ if (storedPrefix == -1 && item.CountsAsClass() && (item.maxStack == 1 || item.AllowReforgeForStackableItem))
+ {
+ // Crafting (or first reforge of) a rogue weapon has a 75% chance for a random modifier, this check is done by vanilla
+ // Negative modifiers have a 66.66% chance of being voided, Annoying modifier is intentionally ignored by vanilla
+ int prefix = CalamityUtils.RandomRoguePrefix();
+ bool keepPrefix = !CalamityUtils.NegativeRoguePrefix(prefix) || Main.rand.NextBool(3);
+ return keepPrefix ? prefix : 0;
+ }
+
+ if (Main.gameMenu)
+ return -1;
+
+ if (item.accessory && CalamityServerConfig.Instance.SimplifyAccessoryReforge)
+ {
+ return GetSimplifiedAccessoryReforge(item, rand, storedPrefix);
+ }
+ else if (storedPrefix != -1 && CalamityServerConfig.Instance.RemoveReforgeRNG)
+ {
+ return GetReworkedReforge(item, rand, storedPrefix);
+ }
+
+ return -1;
+ }
+
+ public override void PostReforge(Item item)
+ {
+ // Bandit steals 20% of the total price of the reforge if she's around.
+ if (NPC.AnyNPCs(NPCType()))
+ {
+ // Calculate the item's reforge cost.
+ int value = item.value;
+ Player p = Main.LocalPlayer;
+ ItemLoader.ReforgePrice(item, ref value, ref p.discountAvailable);
+
+ // Steal 20% of that money.
+ int stolen = value / 5;
+ CalamityWorld.MoneyStolenByBandit += stolen;
+
+ // Increment the reforge counter to allow the Bandit to refund
+ // Also triggers Tinkerer dialogue that hints to the player that money is being stolen
+ CalamityWorld.Reforges++;
+
+ if (Main.netMode == NetmodeID.MultiplayerClient)
+ {
+ BanditStolenMoneySyncPacket.Send(stolen);
+ }
+ }
+ }
+
+ #region Prefix Definition
+ public static int[] SimplifiedAccessoryPrefixes =
+ [
+ PrefixID.Warding,
+ PrefixID.Menacing,
+ PrefixID.Lucky,
+ PrefixID.Quick2,
+ PrefixID.Violent,
+ PrefixID.Arcane,
+ PrefixType(),
+ PrefixType(),
+ PrefixType()
+ ];
+
+ public static int[][] AccessoryPrefixTiers =
+ [
+ /* 0 */ [PrefixID.Hard, PrefixID.Jagged, PrefixID.Brisk, PrefixID.Wild],
+ /* 1 */ [PrefixID.Guarding, PrefixID.Spiked, PrefixID.Precise, PrefixID.Fleeting, PrefixID.Rash],
+ /* 2 */ [PrefixID.Armored, PrefixID.Angry, PrefixID.Hasty2, PrefixID.Intrepid, PrefixID.Arcane],
+ /* 3 */ [PrefixID.Warding, PrefixID.Menacing, PrefixID.Lucky, PrefixID.Quick2, PrefixID.Violent, PrefixType(), PrefixType(), PrefixType()],
+ ];
+
+ public static int[][] TerrarianPrefixTiers =
+ [
+ /* 0 */ [PrefixID.Keen, PrefixID.Forceful, PrefixID.Strong],
+ /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous],
+ /* 2 */ [PrefixID.Superior, PrefixID.Demonic, PrefixID.Godly],
+ /* 3 */ [PrefixID.Legendary2],
+ ];
+
+ public static int[][] MeleePrefixTiers =
+ [
+ /* 0 */ [PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Light, PrefixID.Heavy, PrefixID.Light, PrefixID.Forceful, PrefixID.Strong],
+ /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Pointy, PrefixID.Bulky],
+ /* 2 */ [PrefixID.Murderous, PrefixID.Agile, PrefixID.Large, PrefixID.Dangerous, PrefixID.Sharp],
+ /* 3 */ [PrefixID.Massive, PrefixID.Unpleasant, PrefixID.Savage, PrefixID.Superior],
+ /* 4 */ [PrefixID.Demonic, PrefixID.Deadly2, PrefixID.Godly],
+ /* 5 */ [PrefixID.Legendary] // for non-tools, Light is a mediocre low-tier reforge
+ ];
+
+ public static int[][] MeleeNoSpeedPrefixTiers =
+ [
+ /* 0 */ [PrefixID.Keen, PrefixID.Forceful, PrefixID.Strong],
+ /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous],
+ /* 2 */ [PrefixID.Superior, PrefixID.Demonic],
+ /* 3 */ [PrefixID.Godly]
+ ];
+
+ // 14MAR2025: Ozzatron: Add support for allowing Ruthless over Godly if the player has more than 100% crit chance of the appropriate class
+ public static int[][] MeleeNoSpeedAlwaysCritPrefixTiers =
+ [
+ /* 0 */ [PrefixID.Keen, PrefixID.Forceful, PrefixID.Strong],
+ /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous],
+ /* 2 */ [PrefixID.Superior, PrefixID.Demonic],
+ /* 3 */ [PrefixID.Godly, PrefixID.Ruthless]
+ ];
+
+ public static int[][] ToolPrefixTiers =
+ [
+ /* 0 */ [PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Heavy, PrefixID.Forceful, PrefixID.Strong],
+ /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Pointy, PrefixID.Bulky],
+ /* 2 */ [PrefixID.Murderous, PrefixID.Agile, PrefixID.Large, PrefixID.Dangerous, PrefixID.Sharp],
+ /* 3 */ [PrefixID.Massive, PrefixID.Unpleasant, PrefixID.Savage, PrefixID.Superior],
+ /* 4 */ [PrefixID.Demonic, PrefixID.Deadly2, PrefixID.Godly],
+ /* 5 */ [PrefixID.Legendary, PrefixID.Light] // for some tools, light is better than legendary. for others, it's equal
+ ];
+
+ public static int[][] RangedPrefixTiers =
+ [
+ /* 0 */ [PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Powerful, PrefixID.Forceful, PrefixID.Strong],
+ /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Intimidating],
+ /* 2 */ [PrefixID.Murderous, PrefixID.Agile, PrefixID.Hasty, PrefixID.Staunch, PrefixID.Unpleasant],
+ /* 3 */ [PrefixID.Superior, PrefixID.Demonic, PrefixID.Sighted],
+ /* 4 */ [PrefixID.Godly, PrefixID.Rapid, /* ranged Deadly */ PrefixID.Deadly, /* universal Deadly */ PrefixID.Deadly2],
+ /* 5 */ [PrefixID.Unreal]
+ ];
+
+ public static int[][] MagicPrefixTiers =
+ [
+ /* 0 */ [PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Furious, PrefixID.Forceful, PrefixID.Strong],
+ /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Taboo, PrefixID.Manic],
+ /* 2 */ [PrefixID.Murderous, PrefixID.Agile, PrefixID.Adept, PrefixID.Celestial, PrefixID.Unpleasant],
+ /* 3 */ [PrefixID.Superior, PrefixID.Demonic, PrefixID.Mystic],
+ /* 4 */ [PrefixID.Godly, PrefixID.Masterful, PrefixID.Deadly2],
+ /* 5 */ [PrefixID.Mythical]
+ ];
+
+ public static int[][] SummonPrefixTiers =
+ [
+ /* 0 */ [PrefixID.Nimble, PrefixID.Furious],
+ /* 1 */ [PrefixID.Forceful, PrefixID.Strong, PrefixID.Quick, PrefixID.Taboo, PrefixID.Manic],
+ /* 2 */ [PrefixID.Hurtful, PrefixID.Adept, PrefixID.Celestial],
+ /* 3 */ [PrefixID.Superior, PrefixID.Demonic, PrefixID.Mystic, PrefixID.Deadly2],
+ /* 4 */ [PrefixID.Masterful, PrefixID.Godly],
+ /* 5 */ [PrefixID.Mythical, PrefixID.Ruthless] // you may want mythical early game for the knockback.
+ ];
+
+ // Added appropriate universal reforges to rogue, so they don't ONLY get modded prefixes.
+ public static int[][] RoguePrefixTiers =
+ [
+ /* 0 */ [PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Forceful, PrefixID.Strong, PrefixType(), PrefixType()],
+ /* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixType(), PrefixType()],
+ /* 2 */ [PrefixID.Murderous, PrefixID.Agile, PrefixID.Unpleasant, PrefixType(), PrefixType(), PrefixType()],
+ /* 3 */ [PrefixID.Superior, PrefixID.Demonic, PrefixType(), PrefixType()],
+ /* 4 */ [PrefixID.Godly, PrefixID.Deadly2, PrefixType(), PrefixType()],
+ /* 5 */ [PrefixType()]
+ ];
+ #endregion
+
+ #region Reworked Reforge
+ internal static int GetReworkedReforge(Item item, UnifiedRandom rand, int currentPrefix)
+ {
+ // This is the hardcoded value to "do nothing", and is thus the default choice.
+ int prefix = -1;
+ bool supportsLegendary = PrefixLegacy.ItemSets.SwordsHammersAxesPicks[item.type] || (item.ModItem != null && item.ModItem.MeleePrefix());
+
+ // ACCESSORIES
+ if (item.accessory)
+ {
+ int accRerolls = 0;
+ // Try to prevent the player from rolling the same modifier twice
+ do
+ {
+ int newPrefix = IteratePrefix(rand, AccessoryPrefixTiers, currentPrefix);
+ if (newPrefix != currentPrefix)
+ {
+ prefix = newPrefix;
+ break;
+ }
+ accRerolls++;
+ } while (accRerolls < 20);
+ }
+
+ // MELEE (includes tools and whips)
+ // Melee-ranged hybrid weapons prioritize Legendary if available, otherwise go for Unreal
+ else if ((item.CountsAsClass() || item.CountsAsClass()) && !(item.CountsAsClass() && !supportsLegendary))
+ {
+ // Terrarian (has its own special "Legendary" for marketing reasons)
+ // Other items that want to use Legendary2 are also compatible
+ if (PrefixLegacy.ItemSets.ItemsThatCanHaveLegendary2[item.type])
+ {
+ prefix = IteratePrefix(rand, TerrarianPrefixTiers, currentPrefix);
+ }
+
+ // Swords, Whips, Tools, other items that support the Legendary modifier
+ else if (supportsLegendary)
+ {
+ var tierListToUse = (item.pick > 0 || item.axe > 0 || item.hammer > 0) ? ToolPrefixTiers : MeleePrefixTiers;
+ prefix = IteratePrefix(rand, tierListToUse, currentPrefix);
+ }
+
+ // Yoyos, Flails, Spears, etc.
+ // Spears actually work fine with Legendary, but vanilla doesn't give it to them, so we won't either.
+ else
+ {
+ bool has100Crit = Main.LocalPlayer.GetTotalCritChance(item.DamageType) >= 100;
+ prefix = IteratePrefix(rand, has100Crit ? MeleeNoSpeedAlwaysCritPrefixTiers : MeleeNoSpeedPrefixTiers, currentPrefix);
+ }
+ }
+
+ // RANGED
+ else if (item.CountsAsClass())
+ {
+ prefix = IteratePrefix(rand, RangedPrefixTiers, currentPrefix);
+ }
+
+ // MAGIC
+ else if (item.CountsAsClass() || item.CountsAsClass())
+ {
+ prefix = IteratePrefix(rand, MagicPrefixTiers, currentPrefix);
+ }
+
+ // SUMMON (not whips)
+ else if (item.CountsAsClass())
+ {
+ prefix = IteratePrefix(rand, SummonPrefixTiers, currentPrefix);
+ }
+
+ // ROGUE (Calamity adds these reforges to all 1.4 TML throwing items)
+ else if (item.CountsAsClass())
+ {
+ prefix = IteratePrefix(rand, RoguePrefixTiers, currentPrefix);
+ }
+
+ return prefix;
+ }
+
+ private static int GetPrefixTier(int[][] tiers, int currentPrefix)
+ {
+ for (int checkingTier = 0; checkingTier < tiers.Length; ++checkingTier)
+ {
+ int[] tierList = tiers[checkingTier];
+ for (int i = 0; i < tierList.Length; ++i)
+ if (tierList[i] == currentPrefix)
+ return checkingTier;
+ }
+
+ // If an invalid or modded prefix is detected, return -1.
+ // This will give a random tier 0 prefix (the "next tier"), starting fresh with a low-tier vanilla or Calamity prefix.
+ return -1;
+ }
+
+ private static int IteratePrefix(UnifiedRandom rand, int[][] reforgeTiers, int currentPrefix)
+ {
+ int currentTier = GetPrefixTier(reforgeTiers, currentPrefix);
+
+ // If max tier: give max tier reforges forever
+ // Otherwise: go up by 1 tier with every reforge, guaranteed
+ int newTier = currentTier == reforgeTiers.Length - 1 ? currentTier : currentTier + 1;
+ return rand.Next(reforgeTiers[newTier]);
+ }
+ #endregion
+
+ #region Simplified Accessory Reforge
+ internal static int GetSimplifiedAccessoryReforge(Item item, UnifiedRandom rand, int currentPrefix)
+ {
+ var pool = SimplifiedAccessoryPrefixes.Where(id => id != currentPrefix);
+ return pool.ElementAt(rand.Next(0, pool.Count()));
+ }
+ #endregion
+ }
+}
diff --git a/Projectiles/Boss/RavagerFlame.cs b/Projectiles/Boss/RavagerFlame.cs
index e229838a03..53bc023b24 100644
--- a/Projectiles/Boss/RavagerFlame.cs
+++ b/Projectiles/Boss/RavagerFlame.cs
@@ -1,4 +1,8 @@
-using Terraria;
+using CalamityMod.Events;
+using CalamityMod.Particles;
+using CalamityMod.World;
+using Microsoft.Xna.Framework;
+using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
@@ -27,9 +31,11 @@ namespace CalamityMod.Projectiles.Boss
public override void AI()
{
+ Particle beam3 = new CustomSpark(Projectile.Center, new Vector2(1).RotatedByRandom(6.3f), "CalamityMod/Particles/BloomCircle", false, 10, 0.25f, Color.SkyBlue, new Vector2(1), true, false, 0, false, false, 0f);
+ GeneralParticleHandler.SpawnParticle(beam3);
for (int i = 0; i < 2; i++)
{
- int icyFlame = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.IceTorch, 0f, 0f, 100, default, 3f);
+ int icyFlame = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.IceTorch, 0f, 0f, 100, default, 1.5f);
Main.dust[icyFlame].noGravity = true;
Main.dust[icyFlame].velocity *= 0f;
}
diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs
index a0265ba944..130aae4053 100644
--- a/Projectiles/CalamityGlobalProjectile.cs
+++ b/Projectiles/CalamityGlobalProjectile.cs
@@ -2484,42 +2484,16 @@ namespace CalamityMod.Projectiles
Vector2 vector11 = Main.player[num103].Center - projectile.Center;
float scaleFactor2 = projectile.velocity.Length();
vector11.Normalize();
+ if (vector11.HasNaNs())
+ vector11 = Vector2.Zero;
vector11 *= scaleFactor2;
projectile.velocity = (projectile.velocity * 20f + vector11) / 21f;
projectile.velocity.Normalize();
projectile.velocity *= scaleFactor2;
+ projectile.velocity *= 0.99f;
- // Fly away from other Ice Mists in Master
- if (death)
- {
- float pushForce = 0.06f;
- float pushDistance = 120f;
- for (int k = 0; k < Main.maxProjectiles; k++)
- {
- Projectile otherProj = Main.projectile[k];
- // Short circuits to make the loop as fast as possible
- if (!otherProj.active || k == projectile.whoAmI)
- continue;
-
- // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away
- bool sameProjType = otherProj.type == projectile.type;
- float taxicabDist = Vector2.Distance(projectile.Center, otherProj.Center);
- if (sameProjType && taxicabDist < pushDistance)
- {
- if (projectile.position.X < otherProj.position.X)
- projectile.velocity.X -= pushForce;
- else
- projectile.velocity.X += pushForce;
-
- if (projectile.position.Y < otherProj.position.Y)
- projectile.velocity.Y -= pushForce;
- else
- projectile.velocity.Y += pushForce;
- }
- }
- }
-
- if (projectile.ai[0] % (death ? 30f : 60f) == 0f && Main.netMode != NetmodeID.MultiplayerClient)
+
+ if (projectile.ai[0] % (death ? 20f : 30f) == 0f && Main.netMode != NetmodeID.MultiplayerClient)
{
Vector2 vector50 = projectile.rotation.ToRotationVector2();
Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, vector50, projectile.type, projectile.damage, projectile.knockBack, projectile.owner);
diff --git a/Projectiles/CommonProjectileAI.cs b/Projectiles/CommonProjectileAI.cs
new file mode 100644
index 0000000000..03e846d237
--- /dev/null
+++ b/Projectiles/CommonProjectileAI.cs
@@ -0,0 +1,623 @@
+using System;
+using CalamityMod.CalPlayer;
+using CalamityMod.Enums;
+using CalamityMod.Projectiles.Summon;
+using Microsoft.Xna.Framework;
+using Terraria;
+using Terraria.ID;
+using static Terraria.ModLoader.ModContent;
+
+namespace CalamityMod.Projectiles;
+
+internal static class CommonProjectileAI
+{
+ public static void ChargingMinionAI(this Projectile projectile, float range, float maxPlayerDist, float extraMaxPlayerDist, float safeDist, int initialUpdates, float chargeDelayTime, float goToSpeed, float goBackSpeed, Vector2 returnOffset, float chargeCounterMax, float chargeSpeed, bool tileVision, bool ignoreTilesWhenCharging, int updateDifference = 1)
+ {
+ Player player = Main.player[projectile.owner];
+ CalamityPlayer modPlayer = player.Calamity();
+ projectile.MinionAntiClump();
+
+ //Breather time between charges as like a reset
+ bool chargeDelay = false;
+ if (projectile.ai[0] == 2f)
+ {
+ projectile.ai[1] += 1f;
+ projectile.extraUpdates = initialUpdates + updateDifference;
+ if (projectile.ai[1] > chargeDelayTime)
+ {
+ projectile.ai[1] = 1f;
+ projectile.ai[0] = 0f;
+ projectile.extraUpdates = initialUpdates;
+ // CIT 2OCT2024: This line was breaking how the game counted minions,
+ // which resulted in minions being counted extra times and despawning other minions, most notoriously with Resurrection Butterfly.
+ // As such, I have commented it out.
+ // projectile.numUpdates = 0;
+ projectile.netUpdate = true;
+ }
+ else
+ {
+ chargeDelay = true;
+ }
+ }
+ if (chargeDelay)
+ {
+ return;
+ }
+
+ //Find a target
+ float maxDist = range;
+ Vector2 targetVec = projectile.position;
+ bool foundTarget = false;
+ bool isButterfly = projectile.type == ProjectileType();
+ //Prioritize the targeted enemy if possible
+ if (player.HasMinionAttackTargetNPC)
+ {
+ NPC npc = Main.npc[player.MinionAttackTargetNPC];
+ bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly;
+ if (npc.CanBeChasedBy(projectile, false) || fishronCheck)
+ {
+ //Check the size of the target to make it easier to hit fat targets like Levi
+ float extraDist = (npc.width / 2) + (npc.height / 2);
+
+ float targetDist = Vector2.Distance(npc.Center, projectile.Center);
+ //Some minions will ignore tiles when choosing a target like Ice Claspers, others will not
+ bool canHit = true;
+ if (extraDist < maxDist && !tileVision)
+ canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1);
+ if (!foundTarget && targetDist < (maxDist + extraDist) && canHit)
+ {
+ maxDist = targetDist;
+ targetVec = npc.Center;
+ foundTarget = true;
+ }
+ }
+ }
+ //If no npc is specifically targetted or the selected enemy can't be found, check through the entire array
+ if (!foundTarget)
+ {
+ for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++)
+ {
+ NPC npc = Main.npc[npcIndex];
+ bool fishronCheck = npc.type == NPCID.DukeFishron && npc.active && isButterfly;
+ if (npc.CanBeChasedBy(projectile, false) || fishronCheck)
+ {
+ float extraDist = (npc.width / 2) + (npc.height / 2);
+ float targetDist = Vector2.Distance(npc.Center, projectile.Center);
+ bool canHit = true;
+ if (extraDist < maxDist && !tileVision)
+ canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1);
+ if (!foundTarget && targetDist < (maxDist + extraDist) && canHit)
+ {
+ maxDist = targetDist;
+ targetVec = npc.Center;
+ foundTarget = true;
+ }
+ }
+ }
+ }
+
+ //If the player is too far, return to the player. Range is increased while attacking something.
+ float distBeforeForcedReturn = maxPlayerDist;
+ if (foundTarget)
+ {
+ distBeforeForcedReturn = extraMaxPlayerDist;
+ }
+ if (Vector2.Distance(player.Center, projectile.Center) > distBeforeForcedReturn)
+ {
+ projectile.ai[0] = 1f;
+ projectile.netUpdate = true;
+ }
+
+ //Go to the target if you found one
+ if (foundTarget && projectile.ai[0] == 0f)
+ {
+ //Some minions don't ignore tiles while charging like brittle stars
+ projectile.tileCollide = !ignoreTilesWhenCharging;
+ Vector2 targetSpot = targetVec - projectile.Center;
+ float targetDist = targetSpot.Length();
+ targetSpot.Normalize();
+ //Tries to get the minion in the sweet spot of 200 pixels away but the minion also charges so idk what good it does
+ if (targetDist > 200f)
+ {
+ float speed = goToSpeed; //8
+ targetSpot *= speed;
+ projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f;
+ }
+ else
+ {
+ float speed = -goBackSpeed; //-4
+ targetSpot *= speed;
+ projectile.velocity = (projectile.velocity * 40f + targetSpot) / 41f; //41
+ }
+ }
+
+ //Movement for idle or returning to the player
+ else
+ {
+ //Ignore tiles so they don't get stuck everywhere like Optic Staff
+ projectile.tileCollide = false;
+
+ bool returningToPlayer = false;
+ if (!returningToPlayer)
+ {
+ returningToPlayer = projectile.ai[0] == 1f;
+ }
+
+ //Player distance calculations
+ Vector2 playerVec = player.Center - projectile.Center + returnOffset;
+ float playerDist = playerVec.Length();
+
+ //If the minion is actively returning, move faster
+ float playerHomeSpeed = 6f;
+ if (returningToPlayer)
+ {
+ playerHomeSpeed = 15f;
+ }
+ //Move somewhat faster if the player is kinda far~ish
+ if (playerDist > 200f && playerHomeSpeed < 8f)
+ {
+ playerHomeSpeed = 8f;
+ }
+ //Return to normal if close enough to the player
+ if (playerDist < safeDist && returningToPlayer && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
+ {
+ projectile.ai[0] = 0f;
+ projectile.netUpdate = true;
+ }
+ //Teleport to the player if abnormally far
+ if (playerDist > 2000f)
+ {
+ projectile.position.X = player.Center.X - (float)(projectile.width / 2);
+ projectile.position.Y = player.Center.Y - (float)(projectile.height / 2);
+ projectile.netUpdate = true;
+ }
+ //If more than 70 pixels away, move toward the player
+ if (playerDist > 70f)
+ {
+ playerVec.Normalize();
+ playerVec *= playerHomeSpeed;
+ projectile.velocity = (projectile.velocity * 40f + playerVec) / 41f;
+ }
+ //Minions never stay still
+ else if (projectile.velocity.X == 0f && projectile.velocity.Y == 0f)
+ {
+ projectile.velocity.X = -0.15f;
+ projectile.velocity.Y = -0.05f;
+ }
+ }
+
+ //Increment attack counter randomly
+ if (projectile.ai[1] > 0f)
+ {
+ projectile.ai[1] += (float)Main.rand.Next(1, 4);
+ }
+ //If high enough, prepare to attack
+ if (projectile.ai[1] > chargeCounterMax)
+ {
+ projectile.ai[1] = 0f;
+ projectile.netUpdate = true;
+ }
+
+ //Charge at an enemy if not on cooldown
+ if (projectile.ai[0] == 0f)
+ {
+ if (projectile.ai[1] == 0f && foundTarget && maxDist < 500f)
+ {
+ projectile.ai[1] += 1f;
+ if (Main.myPlayer == projectile.owner)
+ {
+ projectile.ai[0] = 2f;
+ Vector2 targetPos = targetVec - projectile.Center;
+ targetPos.Normalize();
+ projectile.velocity = targetPos * chargeSpeed; //8
+ projectile.netUpdate = true;
+ }
+ }
+ }
+ }
+
+ public static void FloatingPetAI(this Projectile projectile, bool faceRight, float tiltFloat, bool lightPet = false)
+ {
+ Player player = Main.player[projectile.owner];
+
+ //anti sticking movement as a failsafe
+ float SAImovement = 0.05f;
+ for (int k = 0; k < Main.maxProjectiles; k++)
+ {
+ Projectile otherProj = Main.projectile[k];
+ // Short circuits to make the loop as fast as possible
+ if (!otherProj.active || otherProj.owner != projectile.owner || !Main.projPet[otherProj.type] || k == projectile.whoAmI)
+ continue;
+
+ // If the other projectile is indeed another pet owned by the same player and they're too close, nudge them away.
+ bool isPet = Main.projPet[otherProj.type];
+ float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y);
+ if (isPet && taxicabDist < projectile.width)
+ {
+ if (projectile.position.X < otherProj.position.X)
+ projectile.velocity.X -= SAImovement;
+ else
+ projectile.velocity.X += SAImovement;
+
+ if (projectile.position.Y < otherProj.position.Y)
+ projectile.velocity.Y -= SAImovement;
+ else
+ projectile.velocity.Y += SAImovement;
+ }
+ }
+
+ float passiveMvtFloat = 0.5f;
+ projectile.tileCollide = false;
+ float range = 100f;
+ Vector2 projPos = projectile.Center;
+ float xDist = player.Center.X - projPos.X;
+ float yDist = player.Center.Y - projPos.Y;
+ yDist += Main.rand.NextFloat(-10, 20);
+ xDist += Main.rand.NextFloat(-10, 20);
+ //Light pets lead the player, normal pets trail the player
+ xDist += 60f * (lightPet ? (float)player.direction : -(float)player.direction);
+ yDist -= 60f;
+ Vector2 playerVector = new Vector2(xDist, yDist);
+ float playerDist = playerVector.Length();
+ float returnSpeed = 18f;
+
+ //If player is close enough, resume normal
+ if (playerDist < range && player.velocity.Y == 0f &&
+ projectile.Bottom.Y <= player.Bottom.Y &&
+ !Collision.SolidCollision(projectile.position, projectile.width, projectile.height))
+ {
+ if (projectile.velocity.Y < -6f)
+ {
+ projectile.velocity.Y = -6f;
+ }
+ }
+
+ //Teleport to player if too far
+ if (playerDist > 2000f)
+ {
+ projectile.position.X = player.Center.X - projectile.width / 2;
+ projectile.position.Y = player.Center.Y - projectile.height / 2;
+ projectile.netUpdate = true;
+ }
+
+ if (playerDist < 50f)
+ {
+ if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f)
+ {
+ projectile.velocity *= 0.99f;
+ }
+ passiveMvtFloat = 0.01f;
+ }
+ else
+ {
+ if (playerDist < 100f)
+ {
+ passiveMvtFloat = 0.1f;
+ }
+ if (playerDist > 300f)
+ {
+ passiveMvtFloat = 1f;
+ }
+ playerDist = returnSpeed / playerDist;
+ playerVector.X *= playerDist;
+ playerVector.Y *= playerDist;
+ }
+ if (projectile.velocity.X < playerVector.X)
+ {
+ projectile.velocity.X += passiveMvtFloat;
+ if (passiveMvtFloat > 0.05f && projectile.velocity.X < 0f)
+ {
+ projectile.velocity.X += passiveMvtFloat;
+ }
+ }
+ if (projectile.velocity.X > playerVector.X)
+ {
+ projectile.velocity.X -= passiveMvtFloat;
+ if (passiveMvtFloat > 0.05f && projectile.velocity.X > 0f)
+ {
+ projectile.velocity.X -= passiveMvtFloat;
+ }
+ }
+ if (projectile.velocity.Y < playerVector.Y)
+ {
+ projectile.velocity.Y += passiveMvtFloat;
+ if (passiveMvtFloat > 0.05f && projectile.velocity.Y < 0f)
+ {
+ projectile.velocity.Y += passiveMvtFloat * 2f;
+ }
+ }
+ if (projectile.velocity.Y > playerVector.Y)
+ {
+ projectile.velocity.Y -= passiveMvtFloat;
+ if (passiveMvtFloat > 0.05f && projectile.velocity.Y > 0f)
+ {
+ projectile.velocity.Y -= passiveMvtFloat * 2f;
+ }
+ }
+ if (projectile.velocity.X >= 0.25f)
+ {
+ projectile.direction = faceRight ? 1 : -1;
+ }
+ else if (projectile.velocity.X < -0.25f)
+ {
+ projectile.direction = faceRight ? -1 : 1;
+ }
+ //Tilting and change directions
+ projectile.spriteDirection = projectile.direction;
+ projectile.rotation = projectile.velocity.X * tiltFloat;
+ }
+
+ public static void HealingProjectile(this Projectile projectile, int healing, int playerToHeal, float homingVelocity, float inertia, bool autoHomes = true, int timeCheck = 120)
+ {
+ int target = playerToHeal;
+ Player player = Main.player[target];
+ float homingSpeed = homingVelocity;
+ if (player.lifeMagnet)
+ homingSpeed *= 1.5f;
+
+ Vector2 playerVector = player.Center - projectile.Center;
+ float playerDist = playerVector.Length();
+ if (playerDist < 50f && projectile.position.X < player.position.X + player.width && projectile.position.X + projectile.width > player.position.X && projectile.position.Y < player.position.Y + player.height && projectile.position.Y + projectile.height > player.position.Y)
+ {
+ if (projectile.owner == Main.myPlayer && !Main.LocalPlayer.moonLeech)
+ {
+ int healAmt = healing;
+ player.HealPlayer(healAmt, HealTextType.Local);
+ NetMessage.SendData(MessageID.SpiritHeal, -1, -1, null, target, healAmt, 0f, 0f, 0, 0, 0);
+ }
+ projectile.Kill();
+ }
+ if (autoHomes)
+ {
+ playerDist = homingSpeed / playerDist;
+ playerVector.X *= playerDist;
+ playerVector.Y *= playerDist;
+ projectile.velocity.X = (projectile.velocity.X * inertia + playerVector.X) / (inertia + 1f);
+ projectile.velocity.Y = (projectile.velocity.Y * inertia + playerVector.Y) / (inertia + 1f);
+ }
+ else if (player.lifeMagnet && projectile.timeLeft < timeCheck)
+ {
+ playerDist = homingVelocity / playerDist;
+ playerVector.X *= playerDist;
+ playerVector.Y *= playerDist;
+ projectile.velocity.X = (projectile.velocity.X * inertia + playerVector.X) / (inertia + 1f);
+ projectile.velocity.Y = (projectile.velocity.Y * inertia + playerVector.Y) / (inertia + 1f);
+ }
+ }
+
+ public static void MinionAntiClump(this Projectile projectile, float pushForce = 0.05f)
+ {
+ for (int k = 0; k < Main.maxProjectiles; k++)
+ {
+ Projectile otherProj = Main.projectile[k];
+ // Short circuits to make the loop as fast as possible
+ if (!otherProj.active || otherProj.owner != projectile.owner || !otherProj.minion || k == projectile.whoAmI)
+ continue;
+
+ // If the other projectile is indeed the same owned by the same player and they're too close, nudge them away.
+ bool sameProjType = otherProj.type == projectile.type;
+ float taxicabDist = Math.Abs(projectile.position.X - otherProj.position.X) + Math.Abs(projectile.position.Y - otherProj.position.Y);
+ if (sameProjType && taxicabDist < projectile.width)
+ {
+ if (projectile.position.X < otherProj.position.X)
+ projectile.velocity.X -= pushForce;
+ else
+ projectile.velocity.X += pushForce;
+
+ if (projectile.position.Y < otherProj.position.Y)
+ projectile.velocity.Y -= pushForce;
+ else
+ projectile.velocity.Y += pushForce;
+ }
+ }
+ }
+
+ ///
+ /// Call this function in ModifyHitNPC to make your projectiles stick to enemies, needs StickyProjAI to be called in the AI of the projectile
+ ///
+ /// The projectile you're giving sticky behaviour to
+ /// How many projectiles of this type can stick to one enemy
+ public static void ModifyHitNPCSticky(this Projectile projectile, int maxStick)
+ {
+ Player player = Main.player[projectile.owner];
+ Rectangle myRect = projectile.Hitbox;
+
+ if (projectile.owner == Main.myPlayer)
+ {
+ for (int npcIndex = 0; npcIndex < Main.maxNPCs; npcIndex++)
+ {
+ NPC npc = Main.npc[npcIndex];
+ //covers most edge cases like voodoo dolls
+ if (npc.active && !npc.dontTakeDamage &&
+ ((projectile.friendly && (!npc.friendly || (npc.type == NPCID.Guide && projectile.owner < Main.maxPlayers && player.killGuide) || (npc.type == NPCID.Clothier && projectile.owner < Main.maxPlayers && player.killClothier))) ||
+ (projectile.hostile && npc.friendly && !npc.dontTakeDamageFromHostiles)) && (projectile.owner < 0 || npc.immune[projectile.owner] == 0 || projectile.maxPenetrate == 1))
+ {
+ if (npc.noTileCollide || !projectile.ownerHitCheck)
+ {
+ bool stickingToNPC;
+ //Solar Crawltipede tail has special collision
+ if (npc.type == NPCID.SolarCrawltipedeTail)
+ {
+ Rectangle rect = npc.Hitbox;
+ int crawltipedeHitboxMod = 8;
+ rect.X -= crawltipedeHitboxMod;
+ rect.Y -= crawltipedeHitboxMod;
+ rect.Width += crawltipedeHitboxMod * 2;
+ rect.Height += crawltipedeHitboxMod * 2;
+ stickingToNPC = projectile.Colliding(myRect, rect);
+ }
+ else
+ {
+ stickingToNPC = projectile.Colliding(myRect, npc.Hitbox);
+ }
+ if (stickingToNPC)
+ {
+ //reflect projectile if the npc can reflect it (like Selenians)
+ if (npc.reflectsProjectiles && projectile.CanBeReflected())
+ {
+ npc.ReflectProjectile(projectile);
+ return;
+ }
+
+ //let the projectile know it is sticking and the npc it is sticking too
+ projectile.ai[0] = 1f;
+ projectile.ai[1] = (float)npcIndex;
+
+ //follow the NPC
+ projectile.velocity = (npc.Center - projectile.Center);
+
+ projectile.netUpdate = true;
+
+ //Count how many projectiles are attached, delete as necessary
+ Point[] array2 = new Point[maxStick];
+ int projCount = 0;
+ for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++)
+ {
+ Projectile proj = Main.projectile[projIndex];
+ if (projIndex != projectile.whoAmI && proj.active && proj.owner == Main.myPlayer && proj.type == projectile.type && proj.ai[0] == 1f && proj.ai[1] == (float)npcIndex)
+ {
+ array2[projCount++] = new Point(projIndex, proj.timeLeft);
+ if (projCount >= array2.Length)
+ {
+ break;
+ }
+ }
+ }
+ if (projCount >= array2.Length)
+ {
+ int stuckProjAmt = 0;
+ for (int m = 1; m < array2.Length; m++)
+ {
+ if (array2[m].Y < array2[stuckProjAmt].Y)
+ {
+ stuckProjAmt = m;
+ }
+ }
+ Main.projectile[array2[stuckProjAmt].X].Kill();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static void StickToTiles(this Projectile projectile, bool ignorePlatforms, bool stickToEverything)
+ {
+ try
+ {
+ int xLeft = (int)(projectile.position.X / 16f) - 1;
+ int xRight = (int)((projectile.position.X + (float)projectile.width) / 16f) + 2;
+ int yBottom = (int)(projectile.position.Y / 16f) - 1;
+ int yTop = (int)((projectile.position.Y + (float)projectile.height) / 16f) + 2;
+ if (xLeft < 0)
+ {
+ xLeft = 0;
+ }
+ if (xRight > Main.maxTilesX)
+ {
+ xRight = Main.maxTilesX;
+ }
+ if (yBottom < 0)
+ {
+ yBottom = 0;
+ }
+ if (yTop > Main.maxTilesY)
+ {
+ yTop = Main.maxTilesY;
+ }
+ for (int x = xLeft; x < xRight; x++)
+ {
+ for (int y = yBottom; y < yTop; y++)
+ {
+ Tile tile = Main.tile[x, y];
+ bool platformCheck = true;
+ if (ignorePlatforms)
+ platformCheck = !TileID.Sets.Platforms[tile.TileType] && tile.TileType != TileID.PlanterBox;
+ bool tableCheck = false;
+ if (stickToEverything)
+ tableCheck = Main.tileSolidTop[tile.TileType] && tile.TileFrameY == 0;
+ if (tile != null && tile.HasUnactuatedTile && platformCheck && (Main.tileSolid[tile.TileType] || tableCheck))
+ {
+ Vector2 tileSize;
+ tileSize.X = (float)(x * 16);
+ tileSize.Y = (float)(y * 16);
+ if (projectile.position.X + (float)projectile.width - 4f > tileSize.X && projectile.position.X + 4f < tileSize.X + 16f && projectile.position.Y + (float)projectile.height - 4f > tileSize.Y && projectile.position.Y + 4f < tileSize.Y + 16f)
+ {
+ projectile.velocity.X = 0f;
+ projectile.velocity.Y = -0.2f;
+ }
+ }
+ }
+ }
+ }
+ catch
+ {
+ }
+ }
+
+ ///
+ /// Call this function in the ai of your projectile so it can stick to enemies, also requires ModifyHitNPCSticky to be called in ModifyHitNPC
+ ///
+ /// The projectile you're adding sticky behaviour to
+ /// Number of seconds you want a projectile to cling to an NPC
+ public static void StickyProjAI(this Projectile projectile, int timeLeft, bool findNewNPC = false)
+ {
+ if (projectile.ai[0] == 1f)
+ {
+ int seconds = timeLeft;
+ bool killProj = false;
+ bool spawnDust = false;
+
+ //the projectile follows the NPC, even if it goes into blocks
+ projectile.tileCollide = false;
+
+ //timer for triggering hit effects
+ projectile.localAI[0]++;
+ if (projectile.localAI[0] % 30f == 0f)
+ {
+ spawnDust = true;
+ }
+
+ //So AI knows what NPC it is sticking to
+ int npcIndex = (int)projectile.ai[1];
+ NPC npc = Main.npc[npcIndex];
+
+ //Kill projectile after so many seconds or if the NPC it is stuck to no longer exists
+ if (projectile.localAI[0] >= (float)(60 * seconds))
+ {
+ killProj = true;
+ }
+ else if (!npcIndex.WithinBounds(Main.maxNPCs))
+ {
+ killProj = true;
+ }
+
+ else if (npc.active && !npc.dontTakeDamage)
+ {
+ //follow the NPC
+ projectile.Center = npc.Center - projectile.velocity * 2f;
+ projectile.gfxOffY = npc.gfxOffY;
+
+ //if attached to npc, trigger npc hit effects every half a second
+ if (spawnDust)
+ {
+ npc.HitEffect(0, 1.0);
+ }
+ }
+ else
+ {
+ killProj = true;
+ }
+
+ //Kill the projectile or reset stats if needed
+ if (killProj)
+ {
+ if (findNewNPC)
+ projectile.ai[0] = 0f;
+ else
+ projectile.Kill();
+ }
+ }
+ }
+}
diff --git a/Projectiles/Healing/GladiatorHealOrb.cs b/Projectiles/Healing/GladiatorHealOrb.cs
index e7c9296c9a..bbebf4fcd9 100644
--- a/Projectiles/Healing/GladiatorHealOrb.cs
+++ b/Projectiles/Healing/GladiatorHealOrb.cs
@@ -62,7 +62,7 @@ namespace CalamityMod.Projectiles.Healing
public void PassiveBehavior()
{
float maxYVelocity = 2f;
- CalamityUtils.StickToTiles(Projectile, false, false);
+ CommonProjectileAI.StickToTiles(Projectile, false, false);
Projectile.velocity.X *= 0.99f;
if (Projectile.velocity.Y < maxYVelocity)
Projectile.velocity.Y += 0.02f;
diff --git a/Projectiles/Melee/GrandDadHoldout.cs b/Projectiles/Melee/GrandDadHoldout.cs
index 6365934fea..f1151eec3a 100644
--- a/Projectiles/Melee/GrandDadHoldout.cs
+++ b/Projectiles/Melee/GrandDadHoldout.cs
@@ -259,7 +259,7 @@ namespace CalamityMod.Projectiles.Melee
// Apply tile collison damage (is boosted on GFB and even further if both final bosses are gone)
float damageMults = ((DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs) ? 5 : 1) * (Main.zenithWorld ? 77 : 1) * (rightClicked ? 3 : 1);
int damage = (int)(Projectile.damage * damageMults);
- target.FlungNPC().ApplyCollisionDamage(target, Owner, damage, launchVel * launchPower, 5f, true);
+ target.GetGlobalNPC().ApplyCollisionDamage(target, Owner, damage, launchVel * launchPower, 5f, true);
}
if (Projectile.numHits < 3)
diff --git a/Projectiles/Ranged/AdamAcceleratorBeam.cs b/Projectiles/Ranged/AdamAcceleratorBeam.cs
index adbce76797..f8c1737c54 100644
--- a/Projectiles/Ranged/AdamAcceleratorBeam.cs
+++ b/Projectiles/Ranged/AdamAcceleratorBeam.cs
@@ -1,5 +1,6 @@
using System;
using CalamityMod.Items.Weapons.Ranged;
+using CalamityMod.NPCs;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -139,7 +140,7 @@ namespace CalamityMod.Projectiles.Ranged
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
- target.PolarityNPC().applyPolarity(polarity, target); //applies a positive or negative polarity on the target for 120 frames
+ target.GetGlobalNPC().applyPolarity(polarity, target); //applies a positive or negative polarity on the target for 120 frames
}
@@ -147,7 +148,7 @@ namespace CalamityMod.Projectiles.Ranged
{
// Ensure that the hit direction is correct when hitting enemies.
modifiers.HitDirectionOverride = (Projectile.Center.X < target.Center.X).ToDirectionInt();
- float targetPolarity = target.PolarityNPC().CurPolarity;
+ float targetPolarity = target.GetGlobalNPC().CurPolarity;
//If a polarity beam hits the target with the opposite polarity, the damage dealt increases by 20%
if (polarity * targetPolarity < 0)
{
diff --git a/Projectiles/Ranged/Aquashard.cs b/Projectiles/Ranged/Aquashard.cs
index 2731b8fc06..0e33af218e 100644
--- a/Projectiles/Ranged/Aquashard.cs
+++ b/Projectiles/Ranged/Aquashard.cs
@@ -1,51 +1,140 @@
-using Microsoft.Xna.Framework;
+using CalamityMod.Buffs.DamageOverTime;
+using CalamityMod.Buffs.StatDebuffs;
+using CalamityMod.Projectiles.Typeless;
+using Microsoft.Xna.Framework;
+using CalamityMod.Particles;
+using CalamityMod.Tiles.Abyss;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
+using static Terraria.GameContent.Animations.Actions.Sprites;
+using CalamityMod.Dusts;
+using Microsoft.Xna.Framework.Graphics;
+using Terraria.GameContent;
+using CalamityMod.Projectiles.Summon;
namespace CalamityMod.Projectiles.Ranged
{
public class Aquashard : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
+ public int time = 0;
public override void SetDefaults()
{
- Projectile.width = 10;
- Projectile.height = 10;
+ Projectile.width = 20;
+ Projectile.height = 20;
Projectile.friendly = true;
+ Projectile.tileCollide = true;
Projectile.DamageType = DamageClass.Ranged;
Projectile.penetrate = 1;
Projectile.timeLeft = 300;
- Projectile.aiStyle = ProjAIStyleID.Arrow;
}
public override void AI()
{
- Projectile.velocity.X *= 0.9995f;
- Projectile.velocity.Y += 0.01f;
+ //Rotation
+ Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
+ if (time == 1)
+ {
+ Vector2 smokeVel = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 5;
+ int smokeAmount = Main.rand.Next(8, 12 + 1);
+ for (int i = 0; i < smokeAmount; i++)
+ {
+ Particle smoke = new HeavySmokeParticle(Projectile.Center, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(1.2f, 2f), Color.White, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.2f, 0.4f), 0.3f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true);
+ GeneralParticleHandler.SpawnParticle(smoke);
+
+ }
+ for (int i = 0; i < 5; i++)
+ {
+ Particle spark = new GlowSparkParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.8f) * Main.rand.NextFloat(0.2f, 0.4f), false, 12, 0.009f, Color.DarkTurquoise, new Vector2(1.5f, 0.7f), true, false, 1.3f);
+ GeneralParticleHandler.SpawnParticle(spark);
+ }
+ }
+ if (time >= 2)
+ {
+ Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 135 : 279, -Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.05f, 0.2f) - new Vector2(0, 1));
+ dust.scale = Main.rand.NextFloat(0.6f, 0.8f);
+ dust.noGravity = false;
+ }
+ if (time == 14)
+ {
+ Projectile.Kill();
+ }
+ time++;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
{
- int projAmt = Main.rand.Next(1, 3);
- if (Projectile.owner == Main.myPlayer)
+ int projAmt = 3;
+ for (int i = 0; i < projAmt; i++)
{
- for (int i = 0; i < projAmt; i++)
- {
- Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f);
- Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Projectile.owner);
- }
+ Vector2 velocity = CalamityUtils.RandomVelocity(50f, 35f, 50f);
+ Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.3f), 0f, Projectile.owner);
}
+ float offset = Main.rand.NextFloat(MathHelper.TwoPi);
+ for (int i = 0; i < 4; i++)
+ {
+ Vector2 velocity = (MathHelper.TwoPi * i / 4f + offset).ToRotationVector2() * 0.5f;;
+ Particle cross = new SparkParticle(Projectile.Center + velocity * 15f, velocity, false, 15, 1.5f, Color.DarkTurquoise, true);
+ GeneralParticleHandler.SpawnParticle(cross);
+ }
+ for (int k = 0; k < 3; k++)
+ {
+ Particle outerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkSlateBlue, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 0.25f, 25);
+ GeneralParticleHandler.SpawnParticle(outerGlow);
+ Particle innerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkTurquoise, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.4f, 0.15f, 25);
+ GeneralParticleHandler.SpawnParticle(innerGlow);
+ }
+ Player Owner = Main.player[Projectile.owner];
+ if (Owner.Calamity().GeneralScreenShakePower < 1.2f)
+ Owner.Calamity().GeneralScreenShakePower = 1.2f;
+ target.AddBuff(ModContent.BuffType(), 30);
}
public override void OnKill(int timeLeft)
{
- SoundEngine.PlaySound(SoundID.Item27, Projectile.position);
+ SoundEngine.PlaySound(SoundID.DD2_WitherBeastDeath with { Volume = 0.8f }, Projectile.Center);
+ int projAmt = 3;
+ if (Projectile.owner == Main.myPlayer)
+ {
+ for (int i = 0; i < projAmt; i++)
+ {
+ Vector2 velocity = CalamityUtils.RandomVelocity(50f, 35f, 50f);
+ Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Projectile.owner);
+ }
+ }
+ // Create Blast
+ float blastSize = 80;
+ float minMultiplier = 0.25f;
+ int hitsToMinMult = 8;
+ Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25f), 0f, Projectile.owner, blastSize, minMultiplier, hitsToMinMult);
+ blast.DamageType = DamageClass.Ranged;
+ blast.ArmorPenetration = 5;
for (int k = 0; k < 5; k++)
{
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Rain, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
}
+ Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkTurquoise, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(-12, 12), 0f, 0.08f, 22);
+ GeneralParticleHandler.SpawnParticle(blastRing);
+ Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DeepSkyBlue * 0.8f, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.06f, 22, true);
+ GeneralParticleHandler.SpawnParticle(blastRing2);
+ Particle blastRing3 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DeepSkyBlue * 0.8f, "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.2f, 22, true);
+ GeneralParticleHandler.SpawnParticle(blastRing3);
+ for (int i = 0; i < (int)(15); i++)
+ {
+ Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(1f, 1.3f));
+ dust.noGravity = !Main.rand.NextBool();
+ dust.color = Main.rand.NextBool(5) ? Color.DeepSkyBlue : Color.DarkTurquoise;
+ }
+ }
+ public override bool PreDraw(ref Color lightColor)
+ {
+ if (time < 2)
+ {
+ return false;
+ }
+ return base.PreDraw(ref lightColor);
}
}
}
diff --git a/Projectiles/Ranged/Aquashard.png b/Projectiles/Ranged/Aquashard.png
index 0e32025173..54457ff6b4 100644
Binary files a/Projectiles/Ranged/Aquashard.png and b/Projectiles/Ranged/Aquashard.png differ
diff --git a/Projectiles/Ranged/AquashardSplit.cs b/Projectiles/Ranged/AquashardSplit.cs
index a9555374d0..82ce78b9f9 100644
--- a/Projectiles/Ranged/AquashardSplit.cs
+++ b/Projectiles/Ranged/AquashardSplit.cs
@@ -2,13 +2,15 @@
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
+using CalamityMod.Particles;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
namespace CalamityMod.Projectiles.Ranged
{
public class AquashardSplit : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
- public override string Texture => "CalamityMod/Projectiles/Ranged/Aquashard";
public override void SetStaticDefaults() => ProjectileID.Sets.CultistIsResistantTo[Type] = true;
public override void SetDefaults()
@@ -36,10 +38,16 @@ namespace CalamityMod.Projectiles.Ranged
public override void OnKill(int timeLeft)
{
- SoundEngine.PlaySound(SoundID.Item27, Projectile.position);
- for (int k = 0; k < 5; k++)
+ SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact with { Volume = 0.5f, PitchVariance = 0.3f }, Projectile.Center);
+ Particle Star = new CritSpark(Projectile.Center, Vector2.Zero, Color.SkyBlue, Color.DarkTurquoise, Main.rand.NextFloat(1f, 1.1f), 30, 0.1f, 3f);
+ GeneralParticleHandler.SpawnParticle(Star);
+ int num190 = Main.rand.Next(5, 9);
+ for (int i = 0; i < num190; i++)
{
- Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Rain, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
+ int bubbly = Dust.NewDust(Projectile.Center, 0, 0, DustID.UnusedWhiteBluePurple, 0f, 0f, 100, default, 1.4f);
+ Main.dust[bubbly].velocity *= 0.8f;
+ Main.dust[bubbly].position = Vector2.Lerp(Main.dust[bubbly].position, Projectile.Center, 0.5f);
+ Main.dust[bubbly].noGravity = true;
}
}
}
diff --git a/Projectiles/Ranged/AquashardSplit.png b/Projectiles/Ranged/AquashardSplit.png
new file mode 100644
index 0000000000..55f7bbe5a6
Binary files /dev/null and b/Projectiles/Ranged/AquashardSplit.png differ
diff --git a/Projectiles/Ranged/RicoshotCoin.cs b/Projectiles/Ranged/RicoshotCoin.cs
index b8090108e7..f8f2a35d1e 100644
--- a/Projectiles/Ranged/RicoshotCoin.cs
+++ b/Projectiles/Ranged/RicoshotCoin.cs
@@ -1,4 +1,5 @@
using System;
+using CalamityMod.Items;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
@@ -243,7 +244,8 @@ namespace CalamityMod.Projectiles.Ranged
_ => ItemID.CopperCoin,
};
int coin = Item.NewItem(Projectile.GetSource_DropAsItem(), Projectile.Center, Vector2.One, itemID, noBroadcast: false);
- Main.item[coin].Calamity().grabRangeMultiplier = UsedCoinGrabRangeMultiplier;
+ if (Main.item[coin].TryGetGlobalItem(out var grabRangeItem))
+ grabRangeItem.grabRangeMultiplier = UsedCoinGrabRangeMultiplier;
// Sync this dropped coin in multiplayer.
if (Main.netMode == NetmodeID.MultiplayerClient)
diff --git a/Projectiles/Ranged/ShardshockerCrystal.cs b/Projectiles/Ranged/ShardshockerCrystal.cs
new file mode 100644
index 0000000000..75ceacb4f8
--- /dev/null
+++ b/Projectiles/Ranged/ShardshockerCrystal.cs
@@ -0,0 +1,259 @@
+using CalamityMod.Buffs.DamageOverTime;
+using CalamityMod.Buffs.StatDebuffs;
+using CalamityMod.Projectiles.Typeless;
+using Microsoft.Xna.Framework;
+using CalamityMod.Particles;
+using CalamityMod.Tiles.Abyss;
+using Terraria;
+using Terraria.Audio;
+using Terraria.ID;
+using Terraria.ModLoader;
+using static Terraria.GameContent.Animations.Actions.Sprites;
+using CalamityMod.Dusts;
+using Microsoft.Xna.Framework.Graphics;
+using Terraria.GameContent;
+using CalamityMod.Projectiles.Summon;
+using CalamityMod.Projectiles.Melee;
+using System;
+using System.Data;
+using CalamityMod.Items.Ammo;
+
+namespace CalamityMod.Projectiles.Ranged
+{
+ public class ShardshockerCrystal : ModProjectile, ILocalizedModType
+ {
+ public new string LocalizationCategory => "Projectiles.Ranged";
+ public override string Texture => "CalamityMod/Projectiles/Ranged/Aquashard";
+ public static readonly SoundStyle Collision = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeImpact") { Volume = 0.5f };
+ public int time = 0;
+
+ public override void SetDefaults()
+ {
+ Projectile.width = 33;
+ Projectile.height = 33;
+ Projectile.friendly = true;
+ Projectile.tileCollide = true;
+ Projectile.DamageType = DamageClass.Ranged;
+ Projectile.penetrate = 1;
+ Projectile.timeLeft = 240;
+ }
+
+ //The crystal can only damage enemies if it's not hanging in the air
+ public override bool? CanDamage() => time <= 30 ? null : false;
+ public override void AI()
+ {
+ //Set the projectile as traveling and only update rotation while traveling
+ if (time < 30)
+ {
+ Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
+ Projectile.ai[1] = 1f;
+ }
+
+ // Make it lose velocity as it travels
+ Projectile.velocity *= 0.94f;
+ #region Traveling Visuals
+ //Firing effects on frame one
+ if (time == 1)
+ {
+ Vector2 smokeVel = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 5;
+ int smokeAmount = Main.rand.Next(8, 12 + 1);
+ for (int i = 0; i < smokeAmount; i++)
+ {
+ Particle smoke = new HeavySmokeParticle(Projectile.Center, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(1.2f, 2f), Color.White, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.2f, 0.4f), 0.3f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true);
+ GeneralParticleHandler.SpawnParticle(smoke);
+
+ }
+ for (int i = 0; i < 5; i++)
+ {
+ Particle spark = new GlowSparkParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(0.8f) * Main.rand.NextFloat(0.2f, 0.4f), false, 12, 0.009f, Color.DarkTurquoise, new Vector2(1.5f, 0.7f), true, false, 1.3f);
+ GeneralParticleHandler.SpawnParticle(spark);
+ }
+ }
+ //Only spawn dust trails while traveling
+ if (time >= 2 && time <= 30)
+ {
+ Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 135 : 279, -Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.05f, 0.2f) - new Vector2(0, 1));
+ dust.scale = Main.rand.NextFloat(0.6f, 0.8f);
+ dust.noGravity = false;
+ }
+ #endregion
+ //After traveling for 30 frames, come to a stop in the air
+ if (time >= 30)
+ {
+ //Set AI as stopped so traveling crystals can collide with it
+ Projectile.ai[1] = 0f;
+ Projectile.velocity = Vector2.Zero;
+ Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(8f, 10f));
+ Dust spark = Dust.NewDustPerfect(Projectile.Center, 278, velocity);
+ spark.noGravity = true;
+ spark.color = Main.rand.NextBool() ? Color.Aquamarine : Color.LightSkyBlue;
+ if (Main.rand.NextBool(13))
+ {
+ // Create a lightning bolt-like particle in the direction of the shot and 3 random hue-shifted ones by the side
+ Particle bolt = new CrackParticle(Projectile.Center, velocity * 0.5f, Main.rand.NextBool() ? Color.DarkTurquoise : Color.SkyBlue, Vector2.One, 0, 0, Main.rand.NextFloat(0.4f, 0.5f), 12);
+ GeneralParticleHandler.SpawnParticle(bolt);
+
+ for (int i = 1; i < 4; i++)
+ {
+ Particle bolt2 = new CrackParticle(Projectile.Center, velocity.RotatedBy(MathHelper.PiOver2 * i + MathHelper.ToRadians(Main.rand.NextFloat(-40f, 40f))) * 0.5f, Main.rand.NextBool() ? Color.DarkTurquoise : Color.SkyBlue, Vector2.One, 0, 0, Main.rand.NextFloat(0.2f, 0.3f), 12);
+ GeneralParticleHandler.SpawnParticle(bolt2);
+ }
+ }
+ //Create a lightning AoE every second
+ if (time % 60 == 0)
+ {
+ SoundEngine.PlaySound(SoundID.Item93, Projectile.Center);
+ // Create Blast
+ float blastSize = 120;
+ float minMultiplier = 0.25f;
+ int hitsToMinMult = 8;
+ Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), 0f, Projectile.owner, blastSize, minMultiplier, hitsToMinMult);
+ blast.DamageType = DamageClass.Ranged;
+ Particle blastRing3 = new CustomPulse(Projectile.Center, Vector2.Zero, Main.rand.NextBool() ? Color.MediumTurquoise : Color.SkyBlue, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.12f, 30);
+ GeneralParticleHandler.SpawnParticle(blastRing3);
+ }
+ //Set up colliding behavior
+ foreach (Projectile proj in Main.ActiveProjectiles)
+ {
+ // Only allow other large crystals to collide
+ if (proj.type != Type)
+ continue;
+
+ // Check if the colliding crystal is traveling
+ if (proj.ai[1] > 0f && Projectile.Hitbox.Intersects(proj.Hitbox))
+ {
+ SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/LightningAura"), Projectile.Center);
+ //Set on kill effects and kill the stopped crystal
+ Projectile.ai[1] = 2f;
+ Projectile.Kill();
+ //Kill the traveling crystal
+ proj.timeLeft = 0;
+ }
+ }
+ }
+ time++;
+ }
+
+ public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
+ {
+ // Create a smaller AoE on direct hits
+ float blastSize = 130;
+ float minMultiplier = 0.25f;
+ int hitsToMinMult = 4;
+ Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.8f), 0f, Projectile.owner, blastSize, minMultiplier, hitsToMinMult);
+ blast.DamageType = DamageClass.Ranged;
+
+ target.AddBuff(ModContent.BuffType(), 60);
+
+ #region Visuals and Sound
+ SoundEngine.PlaySound(Collision, Projectile.Center);
+
+ Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Main.rand.NextBool() ? Color.MediumAquamarine : Color.DarkSeaGreen, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.1f, 22, true);
+ GeneralParticleHandler.SpawnParticle(blastRing);
+ Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.MediumAquamarine, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(-12, 12), 0f, 0.18f, 22, true);
+ GeneralParticleHandler.SpawnParticle(blastRing2);
+ Particle blastRing3 = new CustomPulse(Projectile.Center, Vector2.Zero, Main.rand.NextBool() ? Color.DarkTurquoise : Color.SkyBlue, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.12f, 22);
+ GeneralParticleHandler.SpawnParticle(blastRing3);
+
+ float offset = Main.rand.NextFloat(MathHelper.TwoPi);
+ for (int i = 0; i < 4; i++)
+ {
+ Vector2 velocity = (MathHelper.TwoPi * i / 4f + offset).ToRotationVector2() * 0.5f; ;
+ Particle cross = new SparkParticle(Projectile.Center + velocity * 15f, velocity, false, 15, 1.5f, Color.MediumAquamarine, true);
+ GeneralParticleHandler.SpawnParticle(cross);
+ }
+ for (int k = 0; k < 3; k++)
+ {
+ Particle outerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkSlateBlue, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 0.25f, 25);
+ GeneralParticleHandler.SpawnParticle(outerGlow);
+ Particle innerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.MediumAquamarine, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.4f, 0.15f, 25);
+ GeneralParticleHandler.SpawnParticle(innerGlow);
+ }
+
+ for (int i = 1; i < 8; i++)
+ {
+ Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(9f, 11f));
+ Dust spark = Dust.NewDustPerfect(Projectile.Center, 278, velocity);
+ spark.color = Main.rand.NextBool() ? Color.Aquamarine : Color.SkyBlue;
+ }
+
+ for (int i = 1; i < 6; i++)
+ {
+ Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(8f, 10f));
+ Particle bolt2 = new CrackParticle(Projectile.Center, velocity.RotatedBy(MathHelper.PiOver2 * i + MathHelper.ToRadians(Main.rand.NextFloat(-40f, 40f))) * 0.5f, Main.rand.NextBool() ? Color.DarkTurquoise : Color.SkyBlue, Vector2.One, 0, 0, Main.rand.NextFloat(0.8f, 1.1f), 17);
+ GeneralParticleHandler.SpawnParticle(bolt2);
+ }
+ #endregion
+ }
+
+ public override void OnKill(int timeLeft)
+ {
+ //These effects only occur if another crystal collides with a stopped one
+ if (Projectile.ai[1] == 2f)
+ {
+ SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/LightningAura"), Projectile.Center);
+ Player Owner = Main.player[Projectile.owner];
+ if (Owner.Calamity().GeneralScreenShakePower < 1.2f)
+ Owner.Calamity().GeneralScreenShakePower = 1.2f;
+ int projAmt = 15;
+ for (int i = 0; i < projAmt; i++)
+ {
+ Vector2 velocity = CalamityUtils.RandomVelocity(50f, 35f, 50f);
+ Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.2f), 0f, Projectile.owner);
+ }
+ float blastSize = 185;
+ float minMultiplier = 0.25f;
+ int hitsToMinMult = 8;
+ int debuff1 = BuffID.Electrified;
+ int debuffTime = 240;
+ Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 4f), 0f, Projectile.owner, blastSize, minMultiplier, hitsToMinMult);
+ blast.localAI[0] = debuff1;
+ blast.localAI[1] = debuffTime;
+ blast.DamageType = DamageClass.Ranged;
+ for (int i = 1; i < 9; i++)
+ {
+ Vector2 velocity = Main.rand.NextVector2Unit() * (Main.rand.NextFloat(8f, 10f));
+ Particle bolt2 = new CrackParticle(Projectile.Center, velocity.RotatedBy(MathHelper.PiOver2 * i + MathHelper.ToRadians(Main.rand.NextFloat(-40f, 40f))) * 0.5f, Main.rand.NextBool() ? Color.DarkTurquoise : Color.SkyBlue, Vector2.One, 0, 0, Main.rand.NextFloat(0.9f, 1.5f), 20);
+ GeneralParticleHandler.SpawnParticle(bolt2);
+ }
+ Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.MediumAquamarine, "CalamityMod/Particles/ShatteredExplosion", Vector2.One, Main.rand.NextFloat(-12, 12), 0f, 0.25f, 25, true);
+ GeneralParticleHandler.SpawnParticle(blastRing);
+ Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Main.rand.NextBool() ? Color.MediumAquamarine : Color.DarkSeaGreen, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.13f, 25, true);
+ GeneralParticleHandler.SpawnParticle(blastRing2);
+ Particle blastRing3 = new CustomPulse(Projectile.Center, Vector2.Zero, Main.rand.NextBool() ? Color.DarkTurquoise : Color.SkyBlue, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.16f, 25, true);
+ GeneralParticleHandler.SpawnParticle(blastRing3);
+ float offset = Main.rand.NextFloat(MathHelper.TwoPi);
+ for (int i = 0; i < 4; i++)
+ {
+ Vector2 velocity = (MathHelper.TwoPi * i / 4f + offset).ToRotationVector2() * 0.5f; ;
+ Particle cross = new SparkParticle(Projectile.Center + velocity * 15f, velocity, false, 15, 2.5f, Color.MediumAquamarine, true);
+ GeneralParticleHandler.SpawnParticle(cross);
+ }
+ for (int k = 0; k < 3; k++)
+ {
+ Particle outerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkSlateBlue, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 0.25f, 25);
+ GeneralParticleHandler.SpawnParticle(outerGlow);
+ Particle innerGlow = new CustomPulse(Projectile.Center, Vector2.Zero, Color.MediumAquamarine, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.4f, 0.15f, 25);
+ GeneralParticleHandler.SpawnParticle(innerGlow);
+ }
+ }
+ //These effects always occur
+ SoundEngine.PlaySound(SoundID.DD2_WitherBeastDeath with { Volume = 0.8f }, Projectile.Center);
+ for (int i = 0; i < (int)(15); i++)
+ {
+ Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), 0, default, Main.rand.NextFloat(1f, 1.3f));
+ dust.noGravity = !Main.rand.NextBool();
+ dust.color = Main.rand.NextBool(5) ? Color.DeepSkyBlue : Color.DarkTurquoise;
+ }
+ }
+ public override bool PreDraw(ref Color lightColor)
+ {
+ //Don't draw the projectile for the first two frames, to prevent it from coming out of the player
+ if (time < 2)
+ {
+ return false;
+ }
+ return base.PreDraw(ref lightColor);
+ }
+ }
+}
diff --git a/Systems/Collections/CalamityItemSets.cs b/Systems/Collections/CalamityItemSets.cs
index 64c8493afb..8d28499100 100644
--- a/Systems/Collections/CalamityItemSets.cs
+++ b/Systems/Collections/CalamityItemSets.cs
@@ -82,5 +82,55 @@ namespace CalamityMod.Systems.Collections
ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType());
+
+ ///
+ /// If for an item type, this item is considered to be a rogue bomb.
+ /// Currently unused, and exists as an objective classification for the sake of the Wiki.
+ /// Defaults to .
+ ///
+ public static bool[] RogueBomb = Factory.CreateBoolSet(ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(), ItemType(), ItemType(), ItemType(), ItemType());
+
+ ///
+ /// If for an item type, this item is considered to be a rogue boomerang.
+ /// Currently unused, and exists as an objective classification for the sake of the Wiki.
+ /// Defaults to .
+ ///
+ public static bool[] RogueBoomerang = Factory.CreateBoolSet(ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(), ItemType(), ItemType(), ItemType(), ItemType());
+
+ ///
+ /// If for an item type, this item is considered to be a rogue dagger.
+ /// Currently unused, and exists as an objective classification for the sake of the Wiki.
+ /// Defaults to .
+ ///
+ public static bool[] RogueDagger = Factory.CreateBoolSet(ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType());
+
+ ///
+ /// If for an item type, this item is considered to be a rogue javelin.
+ /// Currently unused, and exists as an objective classification for the sake of the Wiki.
+ /// Defaults to .
+ ///
+ public static bool[] RogueJavelin = Factory.CreateBoolSet(ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType());
+
+ ///
+ /// If for an item type, this item is considered to be a rogue spiky ball.
+ /// Currently unused, and exists as an objective classification for the sake of the Wiki.
+ /// Defaults to .
+ ///
+ public static bool[] RogueSpikyBall = Factory.CreateBoolSet(ItemType(), ItemType(), ItemType(), ItemType(), ItemType(),
+ ItemType());
}
}
diff --git a/Systems/Graphic/GeneralDrawLayerSystem.cs b/Systems/Graphic/GeneralDrawLayerSystem.cs
new file mode 100644
index 0000000000..e96ef60311
--- /dev/null
+++ b/Systems/Graphic/GeneralDrawLayerSystem.cs
@@ -0,0 +1,131 @@
+using System;
+using CalamityMod.Enums;
+using CalamityMod.Utilities.Daybreak;
+using Terraria;
+using Terraria.ModLoader;
+
+namespace CalamityMod.Systems.Graphic
+{
+ internal sealed class GeneralDrawLayerSystem : ModSystem
+ {
+ public static event Action OnPrepareDraw;
+ public static event Action OnDrawLayer;
+ public static event Action OnDrawLayerLate;
+
+ public static event Action OnBeforeAllTiles;
+ public static event Action OnBeforeSolidTiles;
+ public static event Action OnBeforeNPCs;
+ public static event Action OnAfterNPCs;
+ public static event Action OnBeforeProjectiles;
+ public static event Action OnAfterProjectiles;
+ public static event Action OnAfterPlayers;
+ public static event Action OnAfterDusts;
+ public static event Action OnAfterEverything;
+
+ public override void OnModLoad()
+ {
+ On_Main.CheckMonoliths += CheckMonoliths;
+ On_Main.DrawBackgroundBlackFill += GeneralDrawLayer_DrawToLayer_BeforeAllTiles;
+ On_Main.DoDraw_Tiles_Solid += GeneralDrawLayer_DrawToLayer_BeforeSolidTiles;
+ On_Main.DoDraw_DrawNPCsOverTiles += GeneralDrawLayer_DrawToLayer_NPCs;
+ On_Main.DrawProjectiles += GeneralDrawLayer_DrawToLayer_Projectiles;
+ On_Main.DrawPlayers_AfterProjectiles += GeneralDrawLayer_DrawToLayer_AfterPlayers;
+ On_Main.DrawDust += GeneralDrawLayer_DrawToLayer_AfterDusts;
+ On_Main.DrawInfernoRings += GeneralDrawLayer_DrawToLayer_AfterEverything;
+ }
+
+ public override void Unload()
+ {
+ OnPrepareDraw = null;
+ OnDrawLayer = null;
+ OnDrawLayerLate = null;
+
+ OnBeforeAllTiles = null;
+ OnBeforeSolidTiles = null;
+ OnBeforeNPCs = null;
+ OnAfterNPCs = null;
+ OnBeforeProjectiles = null;
+ OnAfterProjectiles = null;
+ OnAfterPlayers = null;
+ OnAfterDusts = null;
+ OnAfterEverything = null;
+ }
+
+ private static void CheckMonoliths(On_Main.orig_CheckMonoliths orig)
+ {
+ orig();
+ OnPrepareDraw?.Invoke();
+ }
+
+ #region GeneralDrawLayer Systems Drawing
+ private static void GeneralDrawLayer_DrawForLayer(GeneralDrawLayer drawLayer)
+ {
+ OnDrawLayer?.Invoke(drawLayer);
+ OnDrawLayerLate?.Invoke(drawLayer);
+
+ var callback = drawLayer switch
+ {
+ GeneralDrawLayer.BeforeAllTiles => OnBeforeAllTiles,
+ GeneralDrawLayer.BeforeSolidTiles => OnBeforeSolidTiles,
+ GeneralDrawLayer.BeforeNPCs => OnBeforeNPCs,
+ GeneralDrawLayer.AfterNPCs => OnAfterNPCs,
+ GeneralDrawLayer.BeforeProjectiles => OnBeforeProjectiles,
+ GeneralDrawLayer.AfterProjectiles => OnAfterProjectiles,
+ GeneralDrawLayer.AfterPlayers => OnAfterPlayers,
+ GeneralDrawLayer.AfterDusts => OnAfterDusts,
+ GeneralDrawLayer.AfterEverything => OnAfterEverything,
+ _ => null
+ };
+ callback?.Invoke();
+ }
+
+ private static void GeneralDrawLayer_DrawToLayer_BeforeAllTiles(On_Main.orig_DrawBackgroundBlackFill orig, Main self)
+ {
+ Main.spriteBatch.End(out var ss);
+ GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.BeforeAllTiles);
+ Main.spriteBatch.Begin(ss);
+ orig(self);
+ }
+
+ private static void GeneralDrawLayer_DrawToLayer_BeforeSolidTiles(On_Main.orig_DoDraw_Tiles_Solid orig, Main self)
+ {
+ GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.BeforeSolidTiles);
+ orig(self);
+ }
+
+ private static void GeneralDrawLayer_DrawToLayer_NPCs(On_Main.orig_DoDraw_DrawNPCsOverTiles orig, Main self)
+ {
+ GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.BeforeNPCs);
+ orig(self);
+ GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.AfterNPCs);
+ }
+
+ private static void GeneralDrawLayer_DrawToLayer_Projectiles(On_Main.orig_DrawProjectiles orig, Main self)
+ {
+ GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.BeforeProjectiles);
+ orig(self);
+ GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.AfterProjectiles);
+ }
+
+ private static void GeneralDrawLayer_DrawToLayer_AfterPlayers(On_Main.orig_DrawPlayers_AfterProjectiles orig, Main self)
+ {
+ orig(self);
+ GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.AfterPlayers);
+ }
+
+ private static void GeneralDrawLayer_DrawToLayer_AfterDusts(On_Main.orig_DrawDust orig, Main self)
+ {
+ orig(self);
+ GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.AfterDusts);
+ }
+
+ private static void GeneralDrawLayer_DrawToLayer_AfterEverything(On_Main.orig_DrawInfernoRings orig, Main self)
+ {
+ orig(self);
+ Main.spriteBatch.End(out var ss);
+ GeneralDrawLayer_DrawForLayer(GeneralDrawLayer.AfterEverything);
+ Main.spriteBatch.Begin(ss);
+ }
+ #endregion
+ }
+}
diff --git a/Systems/Graphic/PixelationSystem/PixelationManager.cs b/Systems/Graphic/PixelationSystem/PixelationManager.cs
index bfef86b676..151add53f1 100644
--- a/Systems/Graphic/PixelationSystem/PixelationManager.cs
+++ b/Systems/Graphic/PixelationSystem/PixelationManager.cs
@@ -81,7 +81,8 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem
ActivePixelatedDrawers_AfterDusts = [];
ActivePixelatedDrawers_AfterEverything = [];
- On_Main.CheckMonoliths += PrepareTargets;
+ GeneralDrawLayerSystem.OnDrawLayerLate += DrawPixelatedTargets;
+ GeneralDrawLayerSystem.OnPrepareDraw += PrepareTargets;
}
public override void Unload()
@@ -148,7 +149,7 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem
ReturnAssociatedDrawerCollection(drawLayer).Add(drawer);
}
- private static void PrepareTargets(On_Main.orig_CheckMonoliths orig)
+ private static void PrepareTargets()
{
if (!Main.gameMenu && !Main.dedServ)
{
@@ -165,11 +166,8 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem
Main.graphics.GraphicsDevice.SetRenderTarget(null);
}
-
- orig();
-
}
-
+
private static void DrawCollectionsToTarget(Dictionary targetCollection, Matrix pixelationMatrix, List drawerCollection)
{
foreach (var blendStateTargetPair in targetCollection)
@@ -192,17 +190,17 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem
drawerCollection.Clear();
}
- internal static void DrawPixelatedTargets(GeneralDrawLayer drawLayer)
+ private static void DrawPixelatedTargets(GeneralDrawLayer drawLayer)
{
var targetCollection = ReturnAssociatedTargetCollection(drawLayer);
- foreach (var keyValuePair in targetCollection)
- {
- Main.spriteBatch.End();
- Main.spriteBatch.Begin(default, keyValuePair.Key, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
+ foreach (var keyValuePair in targetCollection)
+ {
+ Main.spriteBatch.Begin(default, keyValuePair.Key, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
- float targetScale = 1f / PixelationResolution;
- Main.spriteBatch.Draw(keyValuePair.Value, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, targetScale, SpriteEffects.None, 0f);
- }
+ float targetScale = 1f / PixelationResolution;
+ Main.spriteBatch.Draw(keyValuePair.Value, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, targetScale, SpriteEffects.None, 0f);
+ Main.spriteBatch.End();
+ }
}
private static List ReturnAssociatedDrawerCollection(GeneralDrawLayer drawLayer)
diff --git a/Tiles/Abyss/AbyssTreasureChest.cs b/Tiles/Abyss/AbyssTreasureChest.cs
index 5869ccb838..ff49ab2d56 100644
--- a/Tiles/Abyss/AbyssTreasureChest.cs
+++ b/Tiles/Abyss/AbyssTreasureChest.cs
@@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.Abyss
public override void SetStaticDefaults()
{
this.SetUpChest(ModContent.ItemType());
- AddMapEntry(new Color(71, 49, 41), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName);
+ AddMapEntry(new Color(71, 49, 41), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName);
DustType = DustID.Water;
}
@@ -20,8 +20,8 @@ namespace CalamityMod.Tiles.Abyss
public override void NumDust(int i, int j, bool fail, ref int num) => num = 1;
public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName();
- public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j);
- public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j);
+ public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j);
+ public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j);
public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j);
// Locked Chest stuff
@@ -45,7 +45,7 @@ namespace CalamityMod.Tiles.Abyss
if (tile.TileFrameY != 0)
top--;
- return CalamityUtils.LockedChestRightClick(IsLockedChest(left, top), left, top, i, j);
+ return FurnitureCommon.LockedChestRightClick(IsLockedChest(left, top), left, top, i, j);
}
}
}
diff --git a/Tiles/Abyss/CausticTorch.cs b/Tiles/Abyss/CausticTorch.cs
index 7652b0aafe..6d865de48d 100644
--- a/Tiles/Abyss/CausticTorch.cs
+++ b/Tiles/Abyss/CausticTorch.cs
@@ -71,7 +71,7 @@ namespace CalamityMod.Tiles.Abyss
public override bool RightClick(int i, int j)
{
- CalamityUtils.RightClickBreak(i, j);
+ FurnitureCommon.RightClickBreak(i, j);
return true;
}
diff --git a/Tiles/Abyss/KelpTorch.cs b/Tiles/Abyss/KelpTorch.cs
index d4cd8d673d..45a0591767 100644
--- a/Tiles/Abyss/KelpTorch.cs
+++ b/Tiles/Abyss/KelpTorch.cs
@@ -71,7 +71,7 @@ namespace CalamityMod.Tiles.Abyss
public override bool RightClick(int i, int j)
{
- CalamityUtils.RightClickBreak(i, j);
+ FurnitureCommon.RightClickBreak(i, j);
return true;
}
diff --git a/Tiles/Abyss/RustyChestTile.cs b/Tiles/Abyss/RustyChestTile.cs
index 60a4fd1425..3aac877bf3 100644
--- a/Tiles/Abyss/RustyChestTile.cs
+++ b/Tiles/Abyss/RustyChestTile.cs
@@ -15,9 +15,8 @@ namespace CalamityMod.Tiles.Abyss
public override void SetStaticDefaults()
{
TileType = (ushort)ModContent.TileType();
-
this.SetUpChest(ModContent.ItemType());
- AddMapEntry(new Color(113, 90, 71), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName);
+ AddMapEntry(new Color(113, 90, 71), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName);
}
public override bool CreateDust(int i, int j, ref int type)
@@ -29,9 +28,9 @@ namespace CalamityMod.Tiles.Abyss
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName();
- public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j);
- public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j);
+ public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j);
+ public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j);
public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j);
- public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j);
+ public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j);
}
}
diff --git a/Tiles/Abyss/SulphurousTorch.cs b/Tiles/Abyss/SulphurousTorch.cs
index 22f14ca8df..ccc2a335e7 100644
--- a/Tiles/Abyss/SulphurousTorch.cs
+++ b/Tiles/Abyss/SulphurousTorch.cs
@@ -69,7 +69,7 @@ namespace CalamityMod.Tiles.Abyss
public override bool RightClick(int i, int j)
{
- CalamityUtils.RightClickBreak(i, j);
+ FurnitureCommon.RightClickBreak(i, j);
return true;
}
diff --git a/Tiles/Abyss/ThermalTorch.cs b/Tiles/Abyss/ThermalTorch.cs
index 9052396b33..cb85c60abf 100644
--- a/Tiles/Abyss/ThermalTorch.cs
+++ b/Tiles/Abyss/ThermalTorch.cs
@@ -71,7 +71,7 @@ namespace CalamityMod.Tiles.Abyss
public override bool RightClick(int i, int j)
{
- CalamityUtils.RightClickBreak(i, j);
+ FurnitureCommon.RightClickBreak(i, j);
return true;
}
diff --git a/Tiles/Abyss/VoidTorch.cs b/Tiles/Abyss/VoidTorch.cs
index 49cb21b45c..d64e53ae73 100644
--- a/Tiles/Abyss/VoidTorch.cs
+++ b/Tiles/Abyss/VoidTorch.cs
@@ -72,7 +72,7 @@ namespace CalamityMod.Tiles.Abyss
public override bool RightClick(int i, int j)
{
- CalamityUtils.RightClickBreak(i, j);
+ FurnitureCommon.RightClickBreak(i, j);
return true;
}
diff --git a/Tiles/Astral/AstralChestLocked.cs b/Tiles/Astral/AstralChestLocked.cs
index cb4ea46421..6342c7cac9 100644
--- a/Tiles/Astral/AstralChestLocked.cs
+++ b/Tiles/Astral/AstralChestLocked.cs
@@ -21,15 +21,15 @@ namespace CalamityMod.Tiles.Astral
public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true;
public override void NumDust(int i, int j, bool fail, ref int num) => num = 1;
- public string MapChestName(string name, int i, int j) => CalamityUtils.GetMapChestName(name, i, j);
+ public string MapChestName(string name, int i, int j) => FurnitureCommon.GetMapChestName(name, i, j);
public override ushort GetMapOption(int i, int j) => (ushort)(Main.tile[i, j].TileFrameX / 36);
public override LocalizedText DefaultContainerName(int frameX, int frameY)
{
int option = frameX / 36;
return this.GetLocalization("MapEntry" + option);
}
- public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j);
- public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j);
+ public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j);
+ public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j);
public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j);
// Locked Chest stuff
@@ -57,7 +57,7 @@ namespace CalamityMod.Tiles.Astral
{
top--;
}
- return CalamityUtils.LockedChestRightClick(IsLockedChest(left, top), left, top, i, j);
+ return FurnitureCommon.LockedChestRightClick(IsLockedChest(left, top), left, top, i, j);
}
}
}
diff --git a/Tiles/Astral/AstralTorch.cs b/Tiles/Astral/AstralTorch.cs
index 001d64cfbd..7baa96a23d 100644
--- a/Tiles/Astral/AstralTorch.cs
+++ b/Tiles/Astral/AstralTorch.cs
@@ -73,7 +73,7 @@ namespace CalamityMod.Tiles.Astral
public override bool RightClick(int i, int j)
{
- CalamityUtils.RightClickBreak(i, j);
+ FurnitureCommon.RightClickBreak(i, j);
return true;
}
diff --git a/Tiles/Crags/GloomTorch.cs b/Tiles/Crags/GloomTorch.cs
index ef79994dfd..69804dc76b 100644
--- a/Tiles/Crags/GloomTorch.cs
+++ b/Tiles/Crags/GloomTorch.cs
@@ -72,7 +72,7 @@ namespace CalamityMod.Tiles.Crags
public override bool RightClick(int i, int j)
{
- CalamityUtils.RightClickBreak(i, j);
+ FurnitureCommon.RightClickBreak(i, j);
return true;
}
diff --git a/Tiles/DraedonStructures/AgedSecurityChestTile.cs b/Tiles/DraedonStructures/AgedSecurityChestTile.cs
index 1b462f44d9..428063eef4 100644
--- a/Tiles/DraedonStructures/AgedSecurityChestTile.cs
+++ b/Tiles/DraedonStructures/AgedSecurityChestTile.cs
@@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.DraedonStructures
public override void SetStaticDefaults()
{
this.SetUpChest(ModContent.ItemType());
- AddMapEntry(new Color(130, 119, 115), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName);
+ AddMapEntry(new Color(130, 119, 115), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName);
}
public override bool CanExplode(int i, int j) => false;
@@ -26,9 +26,9 @@ namespace CalamityMod.Tiles.DraedonStructures
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName();
- public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j);
- public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j);
+ public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j);
+ public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j);
public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j);
- public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j);
+ public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j);
}
}
diff --git a/Tiles/DraedonStructures/CagedLights/CagedBiolight.cs b/Tiles/DraedonStructures/CagedLights/CagedBiolight.cs
index 904e594501..4df8d87028 100644
--- a/Tiles/DraedonStructures/CagedLights/CagedBiolight.cs
+++ b/Tiles/DraedonStructures/CagedLights/CagedBiolight.cs
@@ -71,7 +71,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 2);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 2);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/CagedBlacklight.cs b/Tiles/DraedonStructures/CagedLights/CagedBlacklight.cs
index d8ffc484ac..7d0bcbc817 100644
--- a/Tiles/DraedonStructures/CagedLights/CagedBlacklight.cs
+++ b/Tiles/DraedonStructures/CagedLights/CagedBlacklight.cs
@@ -70,7 +70,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
}
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 2);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 2);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/CagedCinderlight.cs b/Tiles/DraedonStructures/CagedLights/CagedCinderlight.cs
index c2884858e1..c69a3f6b30 100644
--- a/Tiles/DraedonStructures/CagedLights/CagedCinderlight.cs
+++ b/Tiles/DraedonStructures/CagedLights/CagedCinderlight.cs
@@ -71,7 +71,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 2);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 2);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/CagedFlamelight.cs b/Tiles/DraedonStructures/CagedLights/CagedFlamelight.cs
index 935dbccfb2..4b54a29dea 100644
--- a/Tiles/DraedonStructures/CagedLights/CagedFlamelight.cs
+++ b/Tiles/DraedonStructures/CagedLights/CagedFlamelight.cs
@@ -71,7 +71,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 2);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 2);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/CagedFloodlight.cs b/Tiles/DraedonStructures/CagedLights/CagedFloodlight.cs
index d0e67fdd15..ab4d4cbdd0 100644
--- a/Tiles/DraedonStructures/CagedLights/CagedFloodlight.cs
+++ b/Tiles/DraedonStructures/CagedLights/CagedFloodlight.cs
@@ -71,7 +71,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 2);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 2);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/CagedFrostlight.cs b/Tiles/DraedonStructures/CagedLights/CagedFrostlight.cs
index 54955f8250..cee6c4998c 100644
--- a/Tiles/DraedonStructures/CagedLights/CagedFrostlight.cs
+++ b/Tiles/DraedonStructures/CagedLights/CagedFrostlight.cs
@@ -71,7 +71,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 2);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 2);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/CagedLablight.cs b/Tiles/DraedonStructures/CagedLights/CagedLablight.cs
index ee4fdc43c3..8d03228245 100644
--- a/Tiles/DraedonStructures/CagedLights/CagedLablight.cs
+++ b/Tiles/DraedonStructures/CagedLights/CagedLablight.cs
@@ -71,7 +71,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 2);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 2);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedBiolight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedBiolight.cs
index aa62e293bd..5b1b1e9ee1 100644
--- a/Tiles/DraedonStructures/CagedLights/MiniCagedBiolight.cs
+++ b/Tiles/DraedonStructures/CagedLights/MiniCagedBiolight.cs
@@ -69,7 +69,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
}
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 1, 1);
+ FurnitureCommon.LightHitWire(Type, i, j, 1, 1);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedBlacklight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedBlacklight.cs
index c8865fe6aa..475f01cf32 100644
--- a/Tiles/DraedonStructures/CagedLights/MiniCagedBlacklight.cs
+++ b/Tiles/DraedonStructures/CagedLights/MiniCagedBlacklight.cs
@@ -69,7 +69,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
}
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 1, 1);
+ FurnitureCommon.LightHitWire(Type, i, j, 1, 1);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedCinderlight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedCinderlight.cs
index 24d14f7795..ed67676391 100644
--- a/Tiles/DraedonStructures/CagedLights/MiniCagedCinderlight.cs
+++ b/Tiles/DraedonStructures/CagedLights/MiniCagedCinderlight.cs
@@ -69,7 +69,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
}
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 1, 1);
+ FurnitureCommon.LightHitWire(Type, i, j, 1, 1);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedFlamelight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedFlamelight.cs
index f20d6bcfde..8d8863731b 100644
--- a/Tiles/DraedonStructures/CagedLights/MiniCagedFlamelight.cs
+++ b/Tiles/DraedonStructures/CagedLights/MiniCagedFlamelight.cs
@@ -69,7 +69,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
}
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 1, 1);
+ FurnitureCommon.LightHitWire(Type, i, j, 1, 1);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedFloodlight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedFloodlight.cs
index 9ce9426dd5..e3bb2773de 100644
--- a/Tiles/DraedonStructures/CagedLights/MiniCagedFloodlight.cs
+++ b/Tiles/DraedonStructures/CagedLights/MiniCagedFloodlight.cs
@@ -69,7 +69,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
}
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 1, 1);
+ FurnitureCommon.LightHitWire(Type, i, j, 1, 1);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedFrostlight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedFrostlight.cs
index bbe83dac01..bac9b21be1 100644
--- a/Tiles/DraedonStructures/CagedLights/MiniCagedFrostlight.cs
+++ b/Tiles/DraedonStructures/CagedLights/MiniCagedFrostlight.cs
@@ -69,7 +69,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
}
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 1, 1);
+ FurnitureCommon.LightHitWire(Type, i, j, 1, 1);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/CagedLights/MiniCagedLablight.cs b/Tiles/DraedonStructures/CagedLights/MiniCagedLablight.cs
index 01863a1516..8b8576b655 100644
--- a/Tiles/DraedonStructures/CagedLights/MiniCagedLablight.cs
+++ b/Tiles/DraedonStructures/CagedLights/MiniCagedLablight.cs
@@ -70,7 +70,7 @@ namespace CalamityMod.Tiles.DraedonStructures.CagedLights
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 1, 1);
+ FurnitureCommon.LightHitWire(Type, i, j, 1, 1);
}
public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
diff --git a/Tiles/DraedonStructures/SecurityChestTile.cs b/Tiles/DraedonStructures/SecurityChestTile.cs
index c9c350c9f9..9ccf53dbb2 100644
--- a/Tiles/DraedonStructures/SecurityChestTile.cs
+++ b/Tiles/DraedonStructures/SecurityChestTile.cs
@@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.DraedonStructures
public override void SetStaticDefaults()
{
this.SetUpChest(ModContent.ItemType());
- AddMapEntry(new Color(130, 119, 115), CalamityUtils.GetItemName(), CalamityUtils.GetMapChestName);
+ AddMapEntry(new Color(130, 119, 115), CalamityUtils.GetItemName(), FurnitureCommon.GetMapChestName);
}
public override bool CanExplode(int i, int j) => false;
@@ -26,9 +26,9 @@ namespace CalamityMod.Tiles.DraedonStructures
public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3;
public override LocalizedText DefaultContainerName(int frameX, int frameY) => CalamityUtils.GetItemName();
- public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver(i, j);
- public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar(i, j);
+ public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver(i, j);
+ public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar(i, j);
public override void KillMultiTile(int i, int j, int frameX, int frameY) => Chest.DestroyChest(i, j);
- public override bool RightClick(int i, int j) => CalamityUtils.ChestRightClick(i, j);
+ public override bool RightClick(int i, int j) => FurnitureCommon.ChestRightClick(i, j);
}
}
diff --git a/Tiles/Furniture/ChaosCandle.cs b/Tiles/Furniture/ChaosCandle.cs
index e6a17f4ca1..518b0fd1da 100644
--- a/Tiles/Furniture/ChaosCandle.cs
+++ b/Tiles/Furniture/ChaosCandle.cs
@@ -53,7 +53,7 @@ namespace CalamityMod.Tiles.Furniture
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 1, 1);
+ FurnitureCommon.LightHitWire(Type, i, j, 1, 1);
}
public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData)
@@ -70,7 +70,7 @@ namespace CalamityMod.Tiles.Furniture
public override bool RightClick(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 1, 1);
+ FurnitureCommon.LightHitWire(Type, i, j, 1, 1);
return true;
}
}
diff --git a/Tiles/Furniture/CraftingStations/ProfanedCrucible.cs b/Tiles/Furniture/CraftingStations/ProfanedCrucible.cs
index ec5a7057d5..eda5725ade 100644
--- a/Tiles/Furniture/CraftingStations/ProfanedCrucible.cs
+++ b/Tiles/Furniture/CraftingStations/ProfanedCrucible.cs
@@ -64,7 +64,7 @@ namespace CalamityMod.Tiles.Furniture.CraftingStations
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 3, 3);
+ FurnitureCommon.LightHitWire(Type, i, j, 3, 3);
}
}
}
diff --git a/Tiles/Furniture/Fountains/AbyssFountainTile.cs b/Tiles/Furniture/Fountains/AbyssFountainTile.cs
index 9bdc67d1b1..1467ee01d5 100644
--- a/Tiles/Furniture/Fountains/AbyssFountainTile.cs
+++ b/Tiles/Furniture/Fountains/AbyssFountainTile.cs
@@ -45,12 +45,12 @@ namespace CalamityMod.Tiles.Furniture.Fountains
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 4);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 4);
}
public override bool RightClick(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 4);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 4);
SoundEngine.PlaySound(SoundID.Mech, new Vector2(i * 16, j * 16));
return true;
}
diff --git a/Tiles/Furniture/Fountains/AstralFountainTile.cs b/Tiles/Furniture/Fountains/AstralFountainTile.cs
index b21b19bd74..f71ee899e1 100644
--- a/Tiles/Furniture/Fountains/AstralFountainTile.cs
+++ b/Tiles/Furniture/Fountains/AstralFountainTile.cs
@@ -46,12 +46,12 @@ namespace CalamityMod.Tiles.Furniture.Fountains
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 4);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 4);
}
public override bool RightClick(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 4);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 4);
SoundEngine.PlaySound(SoundID.Mech, new Vector2(i * 16, j * 16));
return true;
}
diff --git a/Tiles/Furniture/Fountains/BrimstoneLavaFountainTile.cs b/Tiles/Furniture/Fountains/BrimstoneLavaFountainTile.cs
index 6222f06535..d282831cc1 100644
--- a/Tiles/Furniture/Fountains/BrimstoneLavaFountainTile.cs
+++ b/Tiles/Furniture/Fountains/BrimstoneLavaFountainTile.cs
@@ -48,12 +48,12 @@ namespace CalamityMod.Tiles.Furniture.Fountains
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 4);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 4);
}
public override bool RightClick(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 4);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 4);
SoundEngine.PlaySound(SoundID.Mech, new Vector2(i * 16, j * 16));
return true;
}
diff --git a/Tiles/Furniture/Fountains/SulphurousFountainTile.cs b/Tiles/Furniture/Fountains/SulphurousFountainTile.cs
index 6b52380f3d..fee27f16d2 100644
--- a/Tiles/Furniture/Fountains/SulphurousFountainTile.cs
+++ b/Tiles/Furniture/Fountains/SulphurousFountainTile.cs
@@ -46,12 +46,12 @@ namespace CalamityMod.Tiles.Furniture.Fountains
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 4);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 4);
}
public override bool RightClick(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 4);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 4);
SoundEngine.PlaySound(SoundID.Mech, new Vector2(i * 16, j * 16));
return true;
}
diff --git a/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs b/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs
index 52a33930ad..5f6def4b6b 100644
--- a/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs
+++ b/Tiles/Furniture/Fountains/SunkenSeaFountainTile.cs
@@ -45,12 +45,12 @@ namespace CalamityMod.Tiles.Furniture.Fountains
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 4);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 4);
}
public override bool RightClick(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 2, 4);
+ FurnitureCommon.LightHitWire(Type, i, j, 2, 4);
SoundEngine.PlaySound(SoundID.Mech, new Vector2(i * 16, j * 16));
return true;
}
diff --git a/Tiles/Furniture/ThaumaticChairTile.cs b/Tiles/Furniture/ThaumaticChairTile.cs
index 859e31f8bf..3ef7caa652 100644
--- a/Tiles/Furniture/ThaumaticChairTile.cs
+++ b/Tiles/Furniture/ThaumaticChairTile.cs
@@ -24,11 +24,11 @@ namespace CalamityMod.Tiles.Furniture
num = fail ? 1 : 3;
}
- public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.ChairSitInfo(i, j, ref info);
+ public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.ChairSitInfo(i, j, ref info);
- public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j);
+ public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j);
- public override void MouseOver(int i, int j) => CalamityUtils.ChairMouseOver(i, j, ModContent.ItemType());
+ public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType());
public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings)
{
diff --git a/Tiles/Furniture/TranquilityCandle.cs b/Tiles/Furniture/TranquilityCandle.cs
index 3144661cd2..6854f6f549 100644
--- a/Tiles/Furniture/TranquilityCandle.cs
+++ b/Tiles/Furniture/TranquilityCandle.cs
@@ -53,7 +53,7 @@ namespace CalamityMod.Tiles.Furniture
public override void HitWire(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 1, 1);
+ FurnitureCommon.LightHitWire(Type, i, j, 1, 1);
}
public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData)
@@ -70,7 +70,7 @@ namespace CalamityMod.Tiles.Furniture
public override bool RightClick(int i, int j)
{
- CalamityUtils.LightHitWire(Type, i, j, 1, 1);
+ FurnitureCommon.LightHitWire(Type, i, j, 1, 1);
return true;
}
}
diff --git a/Tiles/Furniture/ZenithThrone.cs b/Tiles/Furniture/ZenithThrone.cs
index 580f530341..05373db96d 100644
--- a/Tiles/Furniture/ZenithThrone.cs
+++ b/Tiles/Furniture/ZenithThrone.cs
@@ -74,9 +74,9 @@ namespace CalamityMod.Tiles.Furniture
info.AnchorTilePosition.Y = j;
}
- public override bool RightClick(int i, int j) => CalamityUtils.ChairRightClick(i, j);
+ public override bool RightClick(int i, int j) => FurnitureCommon.ChairRightClick(i, j);
- public override void MouseOver(int i, int j) => CalamityUtils.BenchMouseOver(i, j, ModContent.ItemType());
+ public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType());
public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings)
{
diff --git a/Tiles/FurnitureAbyss/AbyssBed.cs b/Tiles/FurnitureAbyss/AbyssBed.cs
index 8d18164db5..416a691649 100644
--- a/Tiles/FurnitureAbyss/AbyssBed.cs
+++ b/Tiles/FurnitureAbyss/AbyssBed.cs
@@ -23,8 +23,8 @@ namespace CalamityMod.Tiles.FurnitureAbyss
public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true;
- public override bool RightClick(int i, int j) => CalamityUtils.BedRightClick(i, j);
+ public override bool RightClick(int i, int j) => FurnitureCommon.BedRightClick(i, j);
- public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType());
+ public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType