Merge branch '1.4.4' into staging

This commit is contained in:
GinYuH committed 2025-12-16 15:42:43 -08:00
commit 5327e2003d
372 files changed
+4225 -2663

No files matched your search

+13 -10
View File
@@ -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;
}
/// <summary>
/// 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)
+153
View File
@@ -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<RockPillar>() && 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<RockPillar>() && 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
+16 -4
View File
@@ -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<Daybroken>(), 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);
-1
View File
@@ -145,7 +145,6 @@ namespace CalamityMod
ExaltationDirection,
// Syncs for specific bosses or entities
SyncDestroyerLaserColor,
SyncCalamityNPCAIArray,
SyncVanillaNPCLocalAIArray,
SpawnSuperDummy,
+8 -2
View File
@@ -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<Metaball> 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 <see cref="GeneralDrawLayer"/>. Used for layer ordering reasons.
/// </summary>
/// <param name="layerType">The layer type to draw with.</param>
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();
}
}
}
@@ -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<IPixelatedPrimitiveRenderer> 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)
+632 -79
View File
@@ -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<Vector2> 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<Vector2> controlPoints = new();
List<Vector2> 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<float>.Count)
{
var scale = new System.Numerics.Vector<float>(inverseTotal);
int i = 1;
int upperBound = lastIndex - System.Numerics.Vector<float>.Count + 1;
for (; i <= upperBound; i += System.Numerics.Vector<float>.Count)
{
var values = new System.Numerics.Vector<float>(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
}
}
+217 -2
View File
@@ -1,8 +1,125 @@
using Microsoft.Xna.Framework;
using System;
using Microsoft.Xna.Framework;
using Terraria.Graphics.Shaders;
namespace CalamityMod.Graphics.Primitives
{
/// <summary>
/// Controls how U texture coordinates are generated for primitive ribbons.
/// </summary>
public enum PrimitiveTextureMode
{
/// <summary>
/// U coordinates run from 0 to 1 across the full trail length. This matches the legacy behavior.
/// </summary>
Normalized,
/// <summary>
/// U coordinates advance according to distance along the trail. One full texture cycle occurs every <see cref="PrimitiveSettings.TextureCycleLength"/> pixels.
/// </summary>
Distance
}
/// <summary>
/// Controls how adjacent segments are joined together when expanding points into quads.
/// </summary>
public enum PrimitiveJoinStyle
{
/// <summary>
/// Legacy behavior. Each segment is expanded using its forward direction only.
/// </summary>
Flat,
/// <summary>
/// Uses the averaged tangent of neighbouring segments to smooth corners.
/// </summary>
Smooth,
/// <summary>
/// Uses a mitered join to keep width continuous around sharp corners.
/// </summary>
Miter
}
/// <summary>
/// Determines how intermediate sample points are generated for smoothing.
/// </summary>
public enum PrimitiveSmoothingType
{
/// <summary>
/// Classic Catmull-Rom interpolation between points.
/// </summary>
CatmullRom,
/// <summary>
/// Cardinal spline interpolation with configurable tension.
/// </summary>
Cardinal,
/// <summary>
/// Straight-line interpolation between neighbouring points.
/// </summary>
Linear,
/// <summary>
/// Cubic Hermite interpolation using central difference tangents.
/// </summary>
Hermite,
/// <summary>
/// Cubic Bezier interpolation using Catmull-Rom handles.
/// </summary>
CubicBezier
}
/// <summary>
/// Selects how orientation frames propagate along the trail.
/// </summary>
public enum PrimitiveFrameTransportMode
{
/// <summary>
/// Derives the normal from the instantaneous tangent (legacy behaviour).
/// </summary>
Basic,
/// <summary>
/// Uses parallel transport to minimise twisting.
/// </summary>
ParallelTransport
}
/// <summary>
/// Determines the topology used when submitting geometry to the GPU.
/// </summary>
public enum PrimitiveTopology
{
/// <summary>
/// Expands geometry into independent triangles (legacy behaviour).
/// </summary>
TriangleList,
/// <summary>
/// Connects geometry using a continuous triangle strip.
/// </summary>
TriangleStrip
}
/// <summary>
/// Controls how the start and end of the primitive are capped.
/// </summary>
public enum PrimitiveCapStyle
{
/// <summary>
/// Leaves the ribbon open (legacy behaviour).
/// </summary>
None,
/// <summary>
/// Adds a flat triangular cap across the ribbon ends.
/// </summary>
Flat
}
/// <summary>
/// Contains all the various options to use when creating a primitive trail. New members can be added freely without breaking existing implementations.
/// </summary>
@@ -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.
/// </summary>
public readonly (Vector2, Vector2)? InitialVertexPositionsOverride;
/// <summary>
/// Determines how U texture coordinates are generated.
/// </summary>
public readonly PrimitiveTextureMode TextureCoordinateMode;
/// <summary>
/// Controls the scale of generated U coordinates. In <see cref="PrimitiveTextureMode.Normalized"/> this is a multiplier, in <see cref="PrimitiveTextureMode.Distance"/> this is the distance (in pixels) for one full texture cycle.
/// </summary>
public readonly float TextureCycleLength;
/// <summary>
/// Adds an additional offset to the generated U coordinate. In distance mode this value is interpreted in pixels.
/// </summary>
public readonly float TextureScrollOffset;
/// <summary>
/// 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.
/// </summary>
public readonly Func<float, float> TextureCoordinateFunction;
/// <summary>
/// Determines how consecutive segments are joined together when expanding into quads.
/// </summary>
public readonly PrimitiveJoinStyle JoinStyle;
/// <summary>
/// Maximum multiplier applied to miter joins to keep spikes under control.
/// </summary>
public readonly float JoinMiterLimit;
/// <summary>
/// If true, a debug wireframe will be rendered on top of the primitive.
/// </summary>
public readonly bool DebugWireframe;
/// <summary>
/// The color used for the optional wireframe overlay.
/// </summary>
public readonly Color WireframeColor;
/// <summary>
/// Determines the interpolation style when smoothing the provided point list.
/// </summary>
public readonly PrimitiveSmoothingType SmoothingType;
/// <summary>
/// Controls how many intermediate subdivisions are generated per control segment when smoothing. Set to 0 for automatic distribution.
/// </summary>
public readonly int SmoothingSegments;
/// <summary>
/// Additional tension used by smoothing functions that support it (e.g. Cardinal splines).
/// </summary>
public readonly float SmoothingTension;
/// <summary>
/// Determines how normals are transported along the curve.
/// </summary>
public readonly PrimitiveFrameTransportMode FrameTransportMode;
/// <summary>
/// Chooses the primitive topology when submitting geometry to the GPU.
/// </summary>
public readonly PrimitiveTopology Topology;
/// <summary>
/// Determines how the ribbon is capped at its extremities.
/// </summary>
public readonly PrimitiveCapStyle CapStyle;
#endregion
/// <summary>
@@ -85,7 +272,21 @@ namespace CalamityMod.Graphics.Primitives
/// <param name="shader">The shader to apply when rendering the primitives.</param>
/// <param name="useUnscaledMatrices">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.</param>
/// <param name="initialVertexPositionsOverride">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.</param>
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)
/// <param name="textureCoordinateMode">Determines how U texture coordinates are generated.</param>
/// <param name="textureCycleLength">Controls how fast U coordinates advance. Acts as a multiplier in normalized mode, or the distance per cycle in distance mode.</param>
/// <param name="textureScrollOffset">Adds an offset to generated U coordinates. Interpreted in pixels when using distance mode.</param>
/// <param name="textureCoordinateFunction">Optional override that receives the completion ratio and returns a custom U coordinate.</param>
/// <param name="joinStyle">Determines how neighbouring segments are joined when expanding into quads.</param>
/// <param name="joinMiterLimit">Maximum multiplier applied to miter joins to prevent spikes. Only used when <paramref name="joinStyle"/> is <see cref="PrimitiveJoinStyle.Miter"/>.</param>
/// <param name="debugWireframe">When true, draws a wireframe overlay useful for debugging primitive geometry.</param>
/// <param name="wireframeColor">Optional override for the wireframe color. If null, a vivid green is used.</param>
/// <param name="smoothingType">Determines the interpolation style used when smoothing the control points.</param>
/// <param name="smoothingSegments">When greater than zero, specifies the number of subdivisions created per control edge.</param>
/// <param name="smoothingTension">Optional tension parameter used by certain smoothing types such as cardinal splines.</param>
/// <param name="frameTransportMode">Controls how frame orientation is propagated along the curve.</param>
/// <param name="topology">Specifies the primitive topology used when submitting geometry.</param>
/// <param name="capStyle">Selects how the ribbon's start and end are capped.</param>
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<float, float> 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;
}
}
}
+5 -5
View File
@@ -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;
-9
View File
@@ -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;
-70
View File
@@ -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)
{
+39 -92
View File
@@ -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
/// <summary> Tracks the stealth strike damage modifier for this item, derived from its prefix. </summary>
internal float StealthStrikePrefixBonus;
private BitsByte flag0 = 0;
#region Chargeable Item Variables
/// <summary>
/// If set to true, this item will consume <see cref="Charge"/> on use.<br/>
/// Be sure to also set <see cref="MaxCharge"/> and <see cref="ChargePerUse"/>.
/// </summary>
public bool UsesCharge = false;
public bool UsesCharge
{
get => flag0[0];
set => flag0[0] = value;
}
/// <summary> The current charge value of this item. </summary>
public float Charge = 0f;
/// <summary> The maximum charge value of this item. Should only be set if <see cref="UsesCharge"/> is set to true. </summary>
@@ -88,7 +91,11 @@ namespace CalamityMod.Items
#region Enchantment Variables
/// <summary> If set to true, this item cannot receive enchantments from the Brimstone Witch. </summary>
public bool CannotBeEnchanted = false;
public bool CannotBeEnchanted
{
get => flag0[1];
set => flag0[1] = value;
}
/// <summary> Stores the current enchantment placed on this item. If set to null, this item has no enchantment. </summary>
public Enchantment? AppliedEnchantment = null;
/// <summary>
@@ -117,22 +124,29 @@ namespace CalamityMod.Items
/// Set to true if this item can only be obtained in Revengeance Mode.<br/>
/// Adds "Revengeance" to the bottom of the item's tooltip.
/// </summary>
public bool revengeanceItem = false;
public bool revengeanceItem
{
get => flag0[2];
set => flag0[2] = value;
}
/// <summary>
/// Set to true if this item is dedicated to a Patreon donator.<br/>
/// Adds "- Donor Item -" to the bottom of the item's tooltip.
/// </summary>
public bool donorItem = false;
public bool donorItem
{
get => flag0[3];
set => flag0[3] = value;
}
/// <summary>
/// Set to true if this item is dedicated to a Calamity developer.<br/>
/// Adds "- Dev Item -" to the bottom of the item's tooltip.
/// </summary>
public bool devItem = false;
/// <summary>
/// If set to a value greater than 1, applies a multiplier to the item's grab range.<br/>
/// Used by coin items spawned from hitting ricoshot coins.
/// </summary>
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<GrabRangeGlobalItem>(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<RogueDamageClass>() && (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<Bandit>()))
{
// 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 !!
//
+37
View File
@@ -0,0 +1,37 @@
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items;
internal sealed class GrabRangeGlobalItem : GlobalItem
{
/// <summary>
/// If set to a value greater than 1, applies a multiplier to the item's grab range.<br/>
/// Used by coin items spawned from hitting ricoshot coins.
/// </summary>
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
}
-68
View File
@@ -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<Aquashard>();
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<Aquashard>(), 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<AerialiteBar>(2).
AddIngredient<SeaPrism>(10).
AddTile(TileID.Anvils).
Register();
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 999 B

+99
View File
@@ -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<ShardshockerCrystal>();
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<TheBlunderbass>().
AddIngredient<MolluskHusk>(5).
AddIngredient<SeaPrism>(15).
AddIngredient<StormlionMandible>(2).
AddTile(TileID.Anvils).
Register();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

+101
View File
@@ -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<Aquashard>();
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<WulfrumBlunderbuss>().
AddIngredient<Driftwood>(15).
AddIngredient<PearlShard>(3).
AddIngredient<SeaPrism>(7).
AddTile(TileID.Anvils).
Register();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

@@ -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.]
'''
}
}
@@ -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:
@@ -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
+2 -2
View File
@@ -109,7 +109,7 @@ namespace CalamityMod.NPCs
return false;
// Safety check for weird MP bug when getting global npcs.
if (!npc.TryGetGlobalNPCSafer<CalamityGlobalNPC>(out var calNPC) || !npc.TryGetGlobalNPCSafer<CalamityPolarityNPC>(out var polNPC))
if (!npc.TryGetGlobalNPC<CalamityGlobalNPC>(out var calNPC) || !npc.TryGetGlobalNPC<CalamityPolarityNPC>(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<CalamityGlobalNPC>(out var calNPC) || !npc.TryGetGlobalNPCSafer<CalamityPolarityNPC>(out var polNPC))
if (!npc.TryGetGlobalNPC<CalamityGlobalNPC>(out var calNPC) || !npc.TryGetGlobalNPC<CalamityPolarityNPC>(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.
+15 -26
View File
@@ -210,12 +210,6 @@ namespace CalamityMod.NPCs
/// </summary>
private const float BossZenDistance = 6400f;
/// <summary>
/// Destroyer laser colors, used for telegraphs.<br/>
/// None = -1, Red = 0, Green = 1, Cyan = 2
/// </summary>
public int destroyerLaserColor = -1;
/// <summary> Constant multiplier used to decrease the health and/or damage of pre-Hardmode Desert enemies. </summary>
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<DestroyerAI>(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);
}
}
+23
View File
@@ -26,6 +26,24 @@ using static Terraria.ModLoader.ModContent;
namespace CalamityMod.NPCs;
public static class VanillaAIOverrideExtension
{
extension(NPC npc)
{
public bool TryGetAIOverride<AI>(out AI aiInstance) where AI : VanillaAIOverride, new()
{
if (!npc.TryGetGlobalNPC<CalamityVanillaAIOverrideNPC>(out var aiOverrideNPC))
{
aiInstance = null;
return false;
}
aiInstance = aiOverrideNPC.AIOverride as AI;
return aiInstance != null;
}
}
}
public sealed class CalamityVanillaAIOverrideNPC : GlobalNPC
{
/// <summary>
@@ -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
+5 -6
View File
@@ -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;
+42 -3
View File
@@ -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<RavagerFlame>();
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<MeleeDamageClass>())
{
modifiers.FlatBonusDamage += -10000;
modifiers.FinalDamage.Flat += item.pick-1;
modifiers.SetCrit();
}
else
{
modifiers.SetMaxDamage(1);
modifiers.DisableCrit();
modifiers.HideCombatText();
}
base.ModifyHitByProjectile(projectile, ref modifiers);
}
}
}
+29 -17
View File
@@ -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<RockPillar>());
bool anyRockPillars = Main.npc.Any(x => x.active && x.type == ModContent.NPCType<RockPillar>() && x.ai[1] < 2);
bool anyFlamePillars = NPC.AnyNPCs(ModContent.NPCType<FlamePillar>());
if (expertMode)
@@ -593,24 +594,35 @@ namespace CalamityMod.NPCs.Ravager
{
if (n.type == ModContent.NPCType<RockPillar>() && 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<RockPillar>());
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<RockPillar>());
NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X + spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType<RockPillar>());
}
else if (!anyFlamePillars || Main.getGoodWorld)
NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X - spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType<RockPillar>());
NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X + spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType<RockPillar>());
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<FlamePillar>());
@@ -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)
+9 -10
View File
@@ -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;
+9 -10
View File
@@ -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;
+1 -11
View File
@@ -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;
+58 -10
View File
@@ -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<MeleeDamageClass>())
{
modifiers.FlatBonusDamage += -10000;
modifiers.FinalDamage.Flat += item.pick - 1;
modifiers.SetCrit();
}
else
{
modifiers.SetMaxDamage(1);
modifiers.DisableCrit();
modifiers.HideCombatText();
}
base.ModifyHitByProjectile(projectile, ref modifiers);
}
}
}
+110 -115
View File
@@ -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<int> list8 = new List<int>();
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<PrimordialWyrmHead>())
if (Main.npc[(int)NPC.ai[0]].type == ModContent.NPCType<PrimordialWyrmHead>())
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<PrimordialWyrmHead>())
{
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<PrimordialWyrmHead>())
{
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<PrimordialWyrmHead>())
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)
{
@@ -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
/// <summary>
/// Destroyer laser colors, used for telegraphs.<br/>
/// None = -1, Red = 0, Green = 1, Cyan = 2
/// </summary>
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:
@@ -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) { }
/// <summary>
/// This Method should be Implemented If we added our custom field to AI Overrides
/// </summary>
@@ -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;
}
}
}
+4 -1
View File
@@ -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;
+295
View File
@@ -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<RogueDamageClass>() && (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<Bandit>()))
{
// 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<Silent>(),
PrefixType<Invigorating>(),
PrefixType<Dauntless>()
];
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<Silent>(), PrefixType<Dauntless>(), PrefixType<Invigorating>()],
];
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<Radical>(), PrefixType<Pointy>()],
/* 1 */ [PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixType<Sharp>(), PrefixType<Glorious>()],
/* 2 */ [PrefixID.Murderous, PrefixID.Agile, PrefixID.Unpleasant, PrefixType<Feathered>(), PrefixType<Sleek>(), PrefixType<Hefty>()],
/* 3 */ [PrefixID.Superior, PrefixID.Demonic, PrefixType<Mighty>(), PrefixType<Serrated>()],
/* 4 */ [PrefixID.Godly, PrefixID.Deadly2, PrefixType<Vicious>(), PrefixType<Lethal>()],
/* 5 */ [PrefixType<Flawless>()]
];
#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<MeleeDamageClass>() || item.CountsAsClass<SummonMeleeSpeedDamageClass>()) && !(item.CountsAsClass<MeleeRangedHybridDamageClass>() && !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<RangedDamageClass>())
{
prefix = IteratePrefix(rand, RangedPrefixTiers, currentPrefix);
}
// MAGIC
else if (item.CountsAsClass<MagicDamageClass>() || item.CountsAsClass<MagicSummonHybridDamageClass>())
{
prefix = IteratePrefix(rand, MagicPrefixTiers, currentPrefix);
}
// SUMMON (not whips)
else if (item.CountsAsClass<SummonDamageClass>())
{
prefix = IteratePrefix(rand, SummonPrefixTiers, currentPrefix);
}
// ROGUE (Calamity adds these reforges to all 1.4 TML throwing items)
else if (item.CountsAsClass<ThrowingDamageClass>())
{
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
}
}
+8 -2
View File
@@ -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;
}
+5 -31
View File
@@ -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);
+623
View File
@@ -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<PurpleButterfly>();
//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;
}
}
}
/// <summary>
/// Call this function in ModifyHitNPC to make your projectiles stick to enemies, needs StickyProjAI to be called in the AI of the projectile
/// </summary>
/// <param name="projectile">The projectile you're giving sticky behaviour to</param>
/// <param name="maxStick">How many projectiles of this type can stick to one enemy</param>
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
{
}
}
/// <summary>
/// Call this function in the ai of your projectile so it can stick to enemies, also requires ModifyHitNPCSticky to be called in ModifyHitNPC
/// </summary>
/// <param name="projectile">The projectile you're adding sticky behaviour to</param>
/// <param name="timeLeft">Number of seconds you want a projectile to cling to an NPC</param>
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();
}
}
}
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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<CalamityTileCollisionHarmNPC>().ApplyCollisionDamage(target, Owner, damage, launchVel * launchPower, 5f, true);
}
if (Projectile.numHits < 3)
+3 -2
View File
@@ -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<CalamityPolarityNPC>().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<CalamityPolarityNPC>().CurPolarity;
//If a polarity beam hits the target with the opposite polarity, the damage dealt increases by 20%
if (polarity * targetPolarity < 0)
{
+103 -14
View File
@@ -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<AquashardSplit>(), (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<AquashardSplit>(), (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<Eutrophication>(), 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<AquashardSplit>(), (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<BasicBurst>(), (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<LightDust>(), 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);
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 B

After

Width:  |  Height:  |  Size: 826 B

+12 -4
View File
@@ -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;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

+3 -1
View File
@@ -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<GrabRangeGlobalItem>(out var grabRangeItem))
grabRangeItem.grabRangeMultiplier = UsedCoinGrabRangeMultiplier;
// Sync this dropped coin in multiplayer.
if (Main.netMode == NetmodeID.MultiplayerClient)
+259
View File
@@ -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<BasicBurst>(), (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<BasicBurst>(), (int)(Projectile.damage * 0.8f), 0f, Projectile.owner, blastSize, minMultiplier, hitsToMinMult);
blast.DamageType = DamageClass.Ranged;
target.AddBuff(ModContent.BuffType<GalvanicCorrosion>(), 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<AquashardSplit>(), (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<BasicBurst>(), (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<LightDust>(), 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);
}
}
}
+50
View File
@@ -82,5 +82,55 @@ namespace CalamityMod.Systems.Collections
ItemType<AethersWhisper>(), ItemType<AetherfluxCannon>(), ItemType<ApoctosisArray>(), ItemType<Cryophobia>(), ItemType<Effervescence>(), ItemType<EidolicWail>(),
ItemType<Genesis>(), ItemType<IonBlaster>(), ItemType<NanoPurge>(), ItemType<Omicron>(), ItemType<PlasmaCaster>(), ItemType<PlasmaRifle>(), ItemType<PulsePistol>(),
ItemType<PurgeGuzzler>(), ItemType<RainbowPartyCannon>(), ItemType<SHPC>(), ItemType<TeslaCannon>(), ItemType<TheSwarmer>(), ItemType<Volterion>(), ItemType<Vulcan>(), ItemType<Wingman>());
/// <summary>
/// If <see langword="true"/> for an item type, this item is considered to be a rogue bomb.<br/>
/// Currently unused, and exists as an objective classification for the sake of the Wiki.<br/>
/// Defaults to <see langword="false"/>.
/// </summary>
public static bool[] RogueBomb = Factory.CreateBoolSet(ItemType<BallisticPoisonBomb>(), ItemType<BlastBarrel>(), ItemType<ContaminatedBile>(), ItemType<ConsecratedWater>(), ItemType<CraniumSmasher>(),
ItemType<DesecratedWater>(), ItemType<DuststormInABottle>(), ItemType<Exorcism>(), ItemType<LeonidProgenitor>(), ItemType<MeteorFist>(), ItemType<Penumbra>(), ItemType<Plaguenade>(),
ItemType<PlasmaGrenade>(), ItemType<PulseGrenade>(), ItemType<Pumpkaboom>(), ItemType<SeafoamBomb>(), ItemType<SealedSingularity>(), ItemType<SkyfinBombers>(), ItemType<SpentFuelContainer>(),
ItemType<StarofDestruction>(), ItemType<Supernova>(), ItemType<TotalityBreakers>(), ItemType<WavePounder>(), ItemType<Whitewater>());
/// <summary>
/// If <see langword="true"/> for an item type, this item is considered to be a rogue boomerang.<br/>
/// Currently unused, and exists as an objective classification for the sake of the Wiki.<br/>
/// Defaults to <see langword="false"/>.
/// </summary>
public static bool[] RogueBoomerang = Factory.CreateBoolSet(ItemType<AerialTracker>(), ItemType<Brimblade>(), ItemType<Celestus>(), ItemType<DefectiveSphere>(), ItemType<DimensionTearingDisk>(),
ItemType<DynamicPursuer>(), ItemType<EnchantedAxe>(), ItemType<EpidemicShredder>(), ItemType<Equanimity>(), ItemType<FishboneBoomerang>(), ItemType<FrostcrushValari>(), ItemType<GhoulishGouger>(),
ItemType<Icebreaker>(), ItemType<InfestedClawmerang>(), ItemType<KelvinCatalyst>(), ItemType<Kylie>(), ItemType<MangroveChakram>(), ItemType<MoltenAmputator>(), ItemType<NanoblackReaper>(),
ItemType<ReboundingRainbow>(), ItemType<SamsaraSlicer>(), ItemType<SubductionSlicer>(), ItemType<ToxicantTwister>(), ItemType<Valediction>());
/// <summary>
/// If <see langword="true"/> for an item type, this item is considered to be a rogue dagger.<br/>
/// Currently unused, and exists as an objective classification for the sake of the Wiki.<br/>
/// Defaults to <see langword="false"/>.
/// </summary>
public static bool[] RogueDagger = Factory.CreateBoolSet(ItemType<AshenStalactite>(), ItemType<Cinquedea>(), ItemType<Crystalline>(), ItemType<FeatherKnife>(), ItemType<GelDart>(),
ItemType<GildedDagger>(), ItemType<GleamingDagger>(), ItemType<InfernalKris>(), ItemType<Mycoroot>(), ItemType<ShinobiBlade>(), ItemType<SporeKnife>(), ItemType<WulfrumKnife>(),
ItemType<CobaltKunai>(), ItemType<CorpusAvertor>(), ItemType<CursedDagger>(), ItemType<LeviathanTeeth>(), ItemType<Malachite>(), ItemType<MythrilKnife>(), ItemType<OrichalcumSpikedGemstone>(),
ItemType<Prismalline>(), ItemType<RadiantStar>(), ItemType<StellarKnife>(), ItemType<StormfrontRazor>(), ItemType<TerrorTalons>(), ItemType<CosmicKunai>(), ItemType<JawsOfOblivion>(),
ItemType<LunarKunai>(), ItemType<Sacrifice>(), ItemType<Seraphim>(), ItemType<ShatteredDawn>(), ItemType<TarragonThrowingDart>(), ItemType<TimeBolt>(), ItemType<TwistingThunder>(),
ItemType<UtensilPoker>());
/// <summary>
/// If <see langword="true"/> for an item type, this item is considered to be a rogue javelin.<br/>
/// Currently unused, and exists as an objective classification for the sake of the Wiki.<br/>
/// Defaults to <see langword="false"/>.
/// </summary>
public static bool[] RogueJavelin = Factory.CreateBoolSet(ItemType<AntlionSkewer>(), ItemType<CrystalPiercer>(), ItemType<EclipsesFall>(), ItemType<IchorSpear>(), ItemType<NightsGaze>(),
ItemType<PalladiumJavelin>(), ItemType<PhantasmalRuin>(), ItemType<ProfanedPartisan>(), ItemType<RealityRupture>(), ItemType<ScarletDevil>(), ItemType<ScourgeoftheDesert>(),
ItemType<ScourgeoftheSeas>(), ItemType<ShardofAntumbra>(), ItemType<SpearofDestiny>(), ItemType<SpearofPaleolith>(), ItemType<Turbulance>(), ItemType<TheAtomSplitter>(), ItemType<WaveSkipper>(),
ItemType<Wrathwing>());
/// <summary>
/// If <see langword="true"/> for an item type, this item is considered to be a rogue spiky ball.<br/>
/// Currently unused, and exists as an objective classification for the sake of the Wiki.<br/>
/// Defaults to <see langword="false"/>.
/// </summary>
public static bool[] RogueSpikyBall = Factory.CreateBoolSet(ItemType<BurningStrife>(), ItemType<GodsParanoia>(), ItemType<MetalMonstrosity>(), ItemType<NastyCholla>(), ItemType<SystemBane>(),
ItemType<WebBall>());
}
}
+131
View File
@@ -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<GeneralDrawLayer> OnDrawLayer;
public static event Action<GeneralDrawLayer> 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
}
}
@@ -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<BlendState, ManagedRenderTarget> targetCollection, Matrix pixelationMatrix, List<PixelatedDrawer> 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<PixelatedDrawer> ReturnAssociatedDrawerCollection(GeneralDrawLayer drawLayer)
+4 -4
View File
@@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.Abyss
public override void SetStaticDefaults()
{
this.SetUpChest(ModContent.ItemType<Items.Placeables.Furniture.AbyssTreasureChest>());
AddMapEntry(new Color(71, 49, 41), CalamityUtils.GetItemName<Items.Placeables.Furniture.AbyssTreasureChest>(), CalamityUtils.GetMapChestName);
AddMapEntry(new Color(71, 49, 41), CalamityUtils.GetItemName<Items.Placeables.Furniture.AbyssTreasureChest>(), 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<Items.Placeables.Furniture.AbyssTreasureChest>();
public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver<Items.Placeables.Furniture.AbyssTreasureChest>(i, j);
public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar<Items.Placeables.Furniture.AbyssTreasureChest>(i, j);
public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver<Items.Placeables.Furniture.AbyssTreasureChest>(i, j);
public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar<Items.Placeables.Furniture.AbyssTreasureChest>(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);
}
}
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+4 -5
View File
@@ -15,9 +15,8 @@ namespace CalamityMod.Tiles.Abyss
public override void SetStaticDefaults()
{
TileType = (ushort)ModContent.TileType<RustyChestTile>();
this.SetUpChest(ModContent.ItemType<RustyChest>());
AddMapEntry(new Color(113, 90, 71), CalamityUtils.GetItemName<RustyChest>(), CalamityUtils.GetMapChestName);
AddMapEntry(new Color(113, 90, 71), CalamityUtils.GetItemName<RustyChest>(), 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<RustyChest>();
public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver<RustyChest>(i, j);
public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar<RustyChest>(i, j);
public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver<RustyChest>(i, j);
public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar<RustyChest>(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);
}
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+4 -4
View File
@@ -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<AstralChest>(i, j);
public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar<AstralChest>(i, j);
public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver<AstralChest>(i, j);
public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar<AstralChest>(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);
}
}
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
@@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.DraedonStructures
public override void SetStaticDefaults()
{
this.SetUpChest(ModContent.ItemType<AgedSecurityChest>());
AddMapEntry(new Color(130, 119, 115), CalamityUtils.GetItemName<AgedSecurityChest>(), CalamityUtils.GetMapChestName);
AddMapEntry(new Color(130, 119, 115), CalamityUtils.GetItemName<AgedSecurityChest>(), 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<AgedSecurityChest>();
public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver<AgedSecurityChest>(i, j);
public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar<AgedSecurityChest>(i, j);
public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver<AgedSecurityChest>(i, j);
public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar<AgedSecurityChest>(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);
}
}
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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)
+4 -4
View File
@@ -13,7 +13,7 @@ namespace CalamityMod.Tiles.DraedonStructures
public override void SetStaticDefaults()
{
this.SetUpChest(ModContent.ItemType<SecurityChest>());
AddMapEntry(new Color(130, 119, 115), CalamityUtils.GetItemName<SecurityChest>(), CalamityUtils.GetMapChestName);
AddMapEntry(new Color(130, 119, 115), CalamityUtils.GetItemName<SecurityChest>(), 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<SecurityChest>();
public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver<SecurityChest>(i, j);
public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar<SecurityChest>(i, j);
public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver<SecurityChest>(i, j);
public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar<SecurityChest>(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);
}
}
+2 -2
View File
@@ -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;
}
}
@@ -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);
}
}
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
+3 -3
View File
@@ -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<ThaumaticChair>());
public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType<ThaumaticChair>());
public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings)
{
+2 -2
View File
@@ -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;
}
}
+2 -2
View File
@@ -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<Items.Placeables.Furniture.ZenithThrone>());
public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType<Items.Placeables.Furniture.ZenithThrone>());
public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings)
{
+2 -2
View File
@@ -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<Items.Placeables.FurnitureAbyss.AbyssBed>());
public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType<Items.Placeables.FurnitureAbyss.AbyssBed>());
}
}
+1 -1
View File
@@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss
public override void HitWire(int i, int j)
{
CalamityUtils.LightHitWire(Type, i, j, 2, 2);
FurnitureCommon.LightHitWire(Type, i, j, 2, 2);
}
}
}
+2 -2
View File
@@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss
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 MouseOver(int i, int j)
@@ -51,7 +51,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss
public override bool RightClick(int i, int j)
{
CalamityUtils.RightClickBreak(i, j);
FurnitureCommon.RightClickBreak(i, j);
return true;
}
}
+3 -3
View File
@@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurnitureAbyss
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<Items.Placeables.FurnitureAbyss.AbyssChair>());
public override void MouseOver(int i, int j) => FurnitureCommon.ChairMouseOver(i, j, ModContent.ItemType<Items.Placeables.FurnitureAbyss.AbyssChair>());
public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings)
{
+1 -1
View File
@@ -41,7 +41,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss
public override void HitWire(int i, int j)
{
CalamityUtils.LightHitWire(Type, i, j, 3, 3);
FurnitureCommon.LightHitWire(Type, i, j, 3, 3);
}
}
}
+4 -4
View File
@@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss
public override void SetStaticDefaults()
{
this.SetUpChest(ModContent.ItemType<Items.Placeables.FurnitureAbyss.AbyssChest>());
AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName<Items.Placeables.FurnitureAbyss.AbyssChest>(), CalamityUtils.GetMapChestName);
AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName<Items.Placeables.FurnitureAbyss.AbyssChest>(), FurnitureCommon.GetMapChestName);
}
public override bool CreateDust(int i, int j, ref int type)
@@ -24,9 +24,9 @@ namespace CalamityMod.Tiles.FurnitureAbyss
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<Items.Placeables.FurnitureAbyss.AbyssChest>();
public override void MouseOver(int i, int j) => CalamityUtils.ChestMouseOver<Items.Placeables.FurnitureAbyss.AbyssChest>(i, j);
public override void MouseOverFar(int i, int j) => CalamityUtils.ChestMouseFar<Items.Placeables.FurnitureAbyss.AbyssChest>(i, j);
public override void MouseOver(int i, int j) => FurnitureCommon.ChestMouseOver<Items.Placeables.FurnitureAbyss.AbyssChest>(i, j);
public override void MouseOverFar(int i, int j) => FurnitureCommon.ChestMouseFar<Items.Placeables.FurnitureAbyss.AbyssChest>(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);
}
}
+2 -2
View File
@@ -29,7 +29,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss
public override bool RightClick(int x, int y)
{
return CalamityUtils.ClockRightClick();
return FurnitureCommon.ClockRightClick();
}
public override void NearbyEffects(int i, int j, bool closer)
@@ -40,6 +40,6 @@ namespace CalamityMod.Tiles.FurnitureAbyss
}
}
public override void MouseOver(int i, int j) => CalamityUtils.MouseOver(i, j, ModContent.ItemType<Items.Placeables.FurnitureAbyss.AbyssClock>());
public override void MouseOver(int i, int j) => FurnitureCommon.MouseOver(i, j, ModContent.ItemType<Items.Placeables.FurnitureAbyss.AbyssClock>());
}
}
+4 -4
View File
@@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss
public override void SetStaticDefaults()
{
this.SetUpDresser(ModContent.ItemType<Items.Placeables.FurnitureAbyss.AbyssDresser>());
AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName<Items.Placeables.FurnitureAbyss.AbyssDresser>(), CalamityUtils.GetMapChestName);
AddMapEntry(new Color(191, 142, 111), CalamityUtils.GetItemName<Items.Placeables.FurnitureAbyss.AbyssDresser>(), FurnitureCommon.GetMapChestName);
}
public override bool CreateDust(int i, int j, ref int type)
@@ -24,9 +24,9 @@ namespace CalamityMod.Tiles.FurnitureAbyss
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<Items.Placeables.FurnitureAbyss.AbyssDresser>();
public override void MouseOver(int i, int j) => CalamityUtils.DresserMouseOver<Items.Placeables.FurnitureAbyss.AbyssDresser>();
public override void MouseOverFar(int i, int j) => CalamityUtils.DresserMouseFar<Items.Placeables.FurnitureAbyss.AbyssDresser>();
public override void MouseOver(int i, int j) => FurnitureCommon.DresserMouseOver<Items.Placeables.FurnitureAbyss.AbyssDresser>();
public override void MouseOverFar(int i, int j) => FurnitureCommon.DresserMouseFar<Items.Placeables.FurnitureAbyss.AbyssDresser>();
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.DresserRightClick();
public override bool RightClick(int i, int j) => FurnitureCommon.DresserRightClick();
}
}
+1 -1
View File
@@ -38,7 +38,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss
public override void HitWire(int i, int j)
{
CalamityUtils.LightHitWire(Type, i, j, 1, 3);
FurnitureCommon.LightHitWire(Type, i, j, 1, 3);
}
}
}
+1 -1
View File
@@ -40,7 +40,7 @@ namespace CalamityMod.Tiles.FurnitureAbyss
public override void HitWire(int i, int j)
{
CalamityUtils.LightHitWire(Type, i, j, 1, 2);
FurnitureCommon.LightHitWire(Type, i, j, 1, 2);
}
}
}
+3 -3
View File
@@ -23,11 +23,11 @@ namespace CalamityMod.Tiles.FurnitureAbyss
num = fail ? 1 : 3;
}
public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => CalamityUtils.BenchSitInfo(i, j, ref info);
public override void ModifySittingTargetInfo(int i, int j, ref TileRestingInfo info) => FurnitureCommon.BenchSitInfo(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.BenchMouseOver(i, j, ModContent.ItemType<Items.Placeables.FurnitureAbyss.AbyssSofa>());
public override void MouseOver(int i, int j) => FurnitureCommon.BenchMouseOver(i, j, ModContent.ItemType<Items.Placeables.FurnitureAbyss.AbyssSofa>());
public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings)
{
Loaded 100 of 372 files, more files were not shown because too many files have changed in this diff. Show more