Merge branch '1.4.4' into linting
This commit is contained in:
259 files changed
+1491
-542
No files matched your search
+2
-3
@@ -5,8 +5,6 @@ using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CalamityMod.Balancing;
|
||||
using CalamityMod.Buffs.DamageOverTime;
|
||||
using CalamityMod.Buffs.StatDebuffs;
|
||||
using CalamityMod.CalPlayer;
|
||||
using CalamityMod.CalPlayer.Dashes;
|
||||
using CalamityMod.Cooldowns;
|
||||
@@ -14,6 +12,7 @@ using CalamityMod.DataStructures;
|
||||
using CalamityMod.Effects;
|
||||
using CalamityMod.Events;
|
||||
using CalamityMod.FluidSimulation;
|
||||
using CalamityMod.Graphics.Primitives;
|
||||
using CalamityMod.Items;
|
||||
using CalamityMod.Items.Dyes.HairDye;
|
||||
using CalamityMod.Items.VanillaArmorChanges;
|
||||
@@ -34,7 +33,6 @@ using CalamityMod.NPCs.ExoMechs.Artemis;
|
||||
using CalamityMod.NPCs.ExoMechs.Thanatos;
|
||||
using CalamityMod.NPCs.HiveMind;
|
||||
using CalamityMod.NPCs.Leviathan;
|
||||
using CalamityMod.NPCs.NormalNPCs;
|
||||
using CalamityMod.NPCs.OldDuke;
|
||||
using CalamityMod.NPCs.Perforator;
|
||||
using CalamityMod.NPCs.PlaguebringerGoliath;
|
||||
@@ -215,6 +213,7 @@ namespace CalamityMod
|
||||
{
|
||||
LoadClient();
|
||||
GeneralParticleHandler.Load();
|
||||
PrimitiveRenderer.Initialize();
|
||||
ForegroundDrawing.ForegroundManager.Load();
|
||||
|
||||
// Wikithis support
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Shaders;
|
||||
|
||||
namespace CalamityMod.Graphics.Primitives
|
||||
{
|
||||
/// <summary>
|
||||
/// This manages rendering primitives in via the provided <see cref="RenderTrail"/> method.<br/><br/>
|
||||
/// <b>To use normally, in the draw method of an NPC or Projectile call <see cref="RenderTrail"/>.</b><br/>
|
||||
/// <list type="bullet">
|
||||
/// <item>The first param should be the positions to use for the trail.</item>
|
||||
/// <item>The second is a struct that allows you to choose a desired configuration of settings to use with the trail, to allow for customization.</item>
|
||||
/// <item>The third controls how many points are created for the trail, and the fourth determines whether the primitive is subsequently rendered.</item>
|
||||
/// </list>
|
||||
/// If you wish to use pixelation, you <b>MUST</b> make the NPC/Projectile inherit <see cref="IPixelatedPrimitiveRenderer"/> and use <see cref="IPixelatedPrimitiveRenderer.RenderPixelatedPrimitives"/> instead of predraw..<br/>
|
||||
/// You can also optionally specify a render layer with <see cref="IPixelatedPrimitiveRenderer.LayerToRenderTo"/>. It is <see cref="PixelationPrimitiveLayer.BeforeNPCs"/> by default.
|
||||
/// </summary>
|
||||
public static class PrimitiveRenderer
|
||||
{
|
||||
#region Static Members
|
||||
private static DynamicVertexBuffer VertexBuffer;
|
||||
|
||||
private static DynamicIndexBuffer IndexBuffer;
|
||||
|
||||
private static PrimitiveSettings MainSettings;
|
||||
|
||||
private static Vector2[] MainPositions;
|
||||
|
||||
private static VertexPosition2DColorTexture[] MainVertices;
|
||||
|
||||
private static short[] MainIndices;
|
||||
|
||||
private const short MaxPositions = 1000;
|
||||
|
||||
private const short MaxVertices = 3072;
|
||||
|
||||
private const short MaxIndices = 8192;
|
||||
|
||||
private static short PositionsIndex;
|
||||
|
||||
private static short VerticesIndex;
|
||||
|
||||
private static short IndicesIndex;
|
||||
|
||||
internal static void Initialize()
|
||||
{
|
||||
Main.QueueMainThreadAction(() =>
|
||||
{
|
||||
MainPositions = new Vector2[MaxPositions];
|
||||
MainVertices = new VertexPosition2DColorTexture[MaxVertices];
|
||||
MainIndices = new short[MaxIndices];
|
||||
VertexBuffer ??= new DynamicVertexBuffer(Main.instance.GraphicsDevice, VertexPosition2DColorTexture.VertexDeclaration2D, MaxVertices, BufferUsage.WriteOnly);
|
||||
IndexBuffer ??= new DynamicIndexBuffer(Main.instance.GraphicsDevice, IndexElementSize.SixteenBits, MaxIndices, BufferUsage.WriteOnly);
|
||||
});
|
||||
}
|
||||
|
||||
private static void PerformPixelationSafetyChecks(PrimitiveSettings settings)
|
||||
{
|
||||
// Don't allow accidental screw ups with these.
|
||||
if (settings.Pixelate && !PrimitivePixelationSystem.CurrentlyRendering)
|
||||
throw new Exception("Error: Primitives using pixelation MUST be prepared/rendered from the IPixelatedPrimitiveRenderer.RenderPixelatedPrimitives method, did you forget to use the interface?");
|
||||
else if (!settings.Pixelate && PrimitivePixelationSystem.CurrentlyRendering)
|
||||
throw new Exception("Error: Primitives not using pixelation MUST NOT be prepared/rendered from the IPixelatedPrimitiveRenderer.RenderPixelatedPrimitives method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders a primitive trail.
|
||||
/// </summary>
|
||||
/// <param name="positions">The list of positions to use. Keep in mind that these are expected to be in <b>world position</b>, and <see cref="Main.screenPosition"/> is automatically subtracted from them all.<br/>At least 4 points are required to use smoothing.</param>
|
||||
/// <param name="settings">The primitive draw settings to use.</param>
|
||||
/// <param name="pointsToCreate">The amount of points to use. More is higher detailed, but less performant. By default, is the number of positions provided. <b>Going above 100 is NOT recommended.</b></param>
|
||||
public static void RenderTrail(List<Vector2> positions, PrimitiveSettings settings, int? pointsToCreate = null) => RenderTrail(positions.ToArray(), settings, pointsToCreate);
|
||||
|
||||
/// <summary>
|
||||
/// Renders a primitive trail.
|
||||
/// </summary>
|
||||
/// <param name="positions">The list of positions to use. Keep in mind that these are expected to be in <b>world position</b>, and <see cref="Main.screenPosition"/> is automatically subtracted from them all.<br/>At least 4 points are required to use smoothing.</param>
|
||||
/// <param name="settings">The primitive draw settings to use.</param>
|
||||
/// <param name="pointsToCreate">The amount of points to use. More is higher detailed, but less performant. By default, is the number of positions provided. <b>Going above 100 is NOT recommended.</b></param>
|
||||
public static void RenderTrail(Vector2[] positions, PrimitiveSettings settings, int? pointsToCreate = null)
|
||||
{
|
||||
PerformPixelationSafetyChecks(settings);
|
||||
|
||||
// Return if not enough to draw anything.
|
||||
if (positions.Length <= 2)
|
||||
return;
|
||||
|
||||
// Return if too many to draw anything,
|
||||
if (positions.Length >= MaxPositions)
|
||||
return;
|
||||
|
||||
// IF this is false, a correct position trail could not be made and rendering should not continue.
|
||||
if (!AssignPointsRectangleTrail(positions, settings, pointsToCreate ?? positions.Length))
|
||||
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)
|
||||
return;
|
||||
|
||||
MainSettings = settings;
|
||||
|
||||
AssignVerticesRectangleTrail();
|
||||
AssignIndicesRectangleTrail();
|
||||
|
||||
// Else render without wasting resources creating a set.
|
||||
PrivateRender();
|
||||
return;
|
||||
}
|
||||
|
||||
private static void PrivateRender()
|
||||
{
|
||||
if (IndicesIndex % 6 != 0 || VerticesIndex <= 3)
|
||||
return;
|
||||
|
||||
// Perform screen culling, for performance reasons.
|
||||
Main.instance.GraphicsDevice.RasterizerState = RasterizerState.CullNone;
|
||||
Main.instance.GraphicsDevice.RasterizerState.ScissorTestEnable = true;
|
||||
Main.instance.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, Main.screenWidth, Main.screenHeight);
|
||||
|
||||
Matrix view;
|
||||
Matrix projection;
|
||||
if (MainSettings.Pixelate)
|
||||
CalcuatePixelatedPerspectiveMatrices(out view, out projection);
|
||||
else
|
||||
CalamityUtils.CalculatePerspectiveMatricies(out view, out projection);
|
||||
|
||||
var shaderToUse = MainSettings.Shader ?? GameShaders.Misc["CalamityMod:StandardPrimitiveShader"];
|
||||
shaderToUse.Shader.Parameters["uWorldViewProjection"].SetValue(view * projection);
|
||||
shaderToUse.Apply();
|
||||
|
||||
VertexBuffer.SetData(MainVertices, 0, VerticesIndex, SetDataOptions.Discard);
|
||||
IndexBuffer.SetData(MainIndices, 0, IndicesIndex, SetDataOptions.Discard);
|
||||
|
||||
Main.instance.GraphicsDevice.SetVertexBuffer(VertexBuffer);
|
||||
Main.instance.GraphicsDevice.Indices = IndexBuffer;
|
||||
Main.instance.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, VerticesIndex, 0, IndicesIndex / 3);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Set Preperation
|
||||
private static bool AssignPointsRectangleTrail(Vector2[] positions, PrimitiveSettings settings, int pointsToCreate)
|
||||
{
|
||||
// Don't smoothen the points unless explicitly told do so.
|
||||
if (!settings.Smoothen)
|
||||
{
|
||||
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();
|
||||
|
||||
if (positions.Length <= 2)
|
||||
return false;
|
||||
|
||||
// Remap the original positions across a certain length.
|
||||
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];
|
||||
|
||||
// 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;
|
||||
if (settings.OffsetFunction != null)
|
||||
finalPos += settings.OffsetFunction(completionRatio);
|
||||
|
||||
MainPositions[PositionsIndex] = finalPos;
|
||||
PositionsIndex++;
|
||||
}
|
||||
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;
|
||||
|
||||
// Create the control points for the spline.
|
||||
List<Vector2> controlPoints = new();
|
||||
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;
|
||||
|
||||
float completionRatio = i / (float)positions.Length;
|
||||
Vector2 offset = -Main.screenPosition;
|
||||
if (settings.OffsetFunction != null)
|
||||
offset += settings.OffsetFunction(completionRatio);
|
||||
controlPoints.Add(positions[i] + offset);
|
||||
}
|
||||
|
||||
// Avoid stupid index errors.
|
||||
if (controlPoints.Count <= 4)
|
||||
return false;
|
||||
|
||||
for (int j = 0; j < pointsToCreate; j++)
|
||||
{
|
||||
float splineInterpolant = j / (float)pointsToCreate;
|
||||
float localSplineInterpolant = splineInterpolant * (controlPoints.Count - 1f) % 1f;
|
||||
int localSplineIndex = (int)(splineInterpolant * (controlPoints.Count - 1f));
|
||||
|
||||
Vector2 farLeft;
|
||||
Vector2 left = controlPoints[localSplineIndex];
|
||||
Vector2 right = controlPoints[localSplineIndex + 1];
|
||||
Vector2 farRight;
|
||||
|
||||
// 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);
|
||||
PositionsIndex++;
|
||||
}
|
||||
|
||||
// Manually insert the front and end points.
|
||||
MainPositions[0] = controlPoints.First();
|
||||
MainPositions[PositionsIndex] = controlPoints.Last();
|
||||
PositionsIndex++;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void AssignVerticesRectangleTrail()
|
||||
{
|
||||
VerticesIndex = 0;
|
||||
for (int i = 0; i < PositionsIndex; i++)
|
||||
{
|
||||
float completionRatio = i / (float)(PositionsIndex - 1);
|
||||
float widthAtVertex = MainSettings.WidthFunction(completionRatio);
|
||||
Color vertexColor = MainSettings.ColorFunction(completionRatio);
|
||||
Vector2 currentPosition = MainPositions[i];
|
||||
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, 0f);
|
||||
Vector2 rightCurrentTextureCoord = new(completionRatio, 1f);
|
||||
|
||||
// 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;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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);
|
||||
VerticesIndex++;
|
||||
MainVertices[VerticesIndex] = new VertexPosition2DColorTexture(right, vertexColor, rightCurrentTextureCoord);
|
||||
VerticesIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssignIndicesRectangleTrail()
|
||||
{
|
||||
// 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++)
|
||||
{
|
||||
short connectToIndex = (short)(i * 2);
|
||||
MainIndices[IndicesIndex] = connectToIndex;
|
||||
IndicesIndex++;
|
||||
|
||||
MainIndices[IndicesIndex] = (short)(connectToIndex + 1);
|
||||
IndicesIndex++;
|
||||
|
||||
MainIndices[IndicesIndex] = (short)(connectToIndex + 2);
|
||||
IndicesIndex++;
|
||||
|
||||
MainIndices[IndicesIndex] = (short)(connectToIndex + 2);
|
||||
IndicesIndex++;
|
||||
|
||||
MainIndices[IndicesIndex] = (short)(connectToIndex + 1);
|
||||
IndicesIndex++;
|
||||
|
||||
MainIndices[IndicesIndex] = (short)(connectToIndex + 3);
|
||||
IndicesIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void CalcuatePixelatedPerspectiveMatrices(out Matrix viewMatrix, out Matrix projectionMatrix)
|
||||
{
|
||||
// Due to the scaling, the normal transformation calcuations do not work with pixelated primitives.
|
||||
projectionMatrix = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -1, 1);
|
||||
viewMatrix = Matrix.Identity;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,296 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Graphics.Shaders;
|
||||
|
||||
namespace CalamityMod.Graphics.Primitives
|
||||
{
|
||||
/// <summary>
|
||||
/// This both acts as an instanceable struct containing primitive trail data, and as a manager that creates and renders said instances. <br/><br/>
|
||||
/// <b>To use normally, in the draw method of an NPC or Projectile call <see cref="Prepare"/>.</b><br/>
|
||||
/// <list type="bullet">
|
||||
/// <item>The first param should be the positions to use for the trail.</item>
|
||||
/// <item>The second is a struct that allows you to choose a desired configuration of settings to use with the trail, to allow for customization.</item>
|
||||
/// <item>The third controls how many points are created for the trail, and the fourth determines whether the primitive is subsequently rendered.</item>
|
||||
/// <item>If you do not render in <see cref="Prepare"/>, you <b>MUST</b> call <see cref="Render"/> manually on the created instance to make it actually appear.</item>
|
||||
/// </list>
|
||||
/// If you wish to use pixelation, you <b>MUST</b> make the NPC/Projectile inherit <see cref="IPixelatedPrimitiveRenderer"/> and use <see cref="IPixelatedPrimitiveRenderer.RenderPixelatedPrimitives"/> instead.<br/>
|
||||
/// You can also optionally specify a render layer with <see cref="IPixelatedPrimitiveRenderer.LayerToRenderTo"/>. It is <see cref="PixelationPrimitiveLayer.BeforeNPCs"/> by default.
|
||||
/// </summary>
|
||||
public readonly struct PrimitiveSet
|
||||
{
|
||||
#region Instance Members
|
||||
/// <summary>
|
||||
/// The vertices of the set.
|
||||
/// </summary>
|
||||
public readonly VertexPosition2DColorTexture[] Vertices;
|
||||
|
||||
/// <summary>
|
||||
/// The indices of the set.
|
||||
/// </summary>
|
||||
public readonly int[] Indices;
|
||||
|
||||
/// <summary>
|
||||
/// The settings of the set.
|
||||
/// </summary>
|
||||
public readonly PrimitiveSettings Settings;
|
||||
|
||||
private PrimitiveSet(VertexPosition2DColorTexture[] vertices, int[] indices, PrimitiveSettings settings)
|
||||
{
|
||||
Vertices = vertices;
|
||||
Indices = indices;
|
||||
Settings = settings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Static Members
|
||||
private static void PerformPixelationSafetyChecks(PrimitiveSettings settings)
|
||||
{
|
||||
// Don't allow accidental screw ups with these.
|
||||
if (settings.Pixelate && !PrimitivePixelationSystem.CurrentlyRendering)
|
||||
throw new Exception("Error: Primitives using pixelation MUST be prepared/rendered from the IPixelatedPrimitiveRenderer.RenderPixelatedPrimitives method, did you forget to use the interface?");
|
||||
else if (!settings.Pixelate && PrimitivePixelationSystem.CurrentlyRendering)
|
||||
throw new Exception("Error: Primitives not using pixelation MUST NOT be prepared/rendered from the IPixelatedPrimitiveRenderer.RenderPixelatedPrimitives method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepares a <see cref="PrimitiveSet"/> based on the provided information, and optionally renders it.
|
||||
/// </summary>
|
||||
/// <param name="positions">The list of positions to use. Keep in mind that these are expected to be in <b>world position</b>, and <see cref="Main.screenPosition"/> is automatically subtracted from them all.</param>
|
||||
/// <param name="settings">The primitive draw settings to use.</param>
|
||||
/// <param name="pointsToCreate">The amount of points to use. More is higher detailed, but less performant. By default, is the number of positions provided. <b>Going above 100 is NOT recommended.</b></param>
|
||||
/// <param name="render">Whether to render the set.</param>
|
||||
/// <returns>The prepared set.</returns>
|
||||
public static PrimitiveSet? Prepare(IEnumerable<Vector2> positions, PrimitiveSettings settings, int? pointsToCreate = null, bool render = true)
|
||||
{
|
||||
PerformPixelationSafetyChecks(settings);
|
||||
|
||||
int positionCount = positions.Count();
|
||||
|
||||
// Return if not enough to draw anything.
|
||||
if (positionCount <= 2)
|
||||
return null;
|
||||
|
||||
// Cull out any zeroed points.
|
||||
positions = positions.Where(p => p != Vector2.Zero);
|
||||
List<Vector2> trailPoints = PreparePointsRectangleTrail(positions, settings, pointsToCreate ?? positionCount).ToList();
|
||||
|
||||
// A trail with only one point or less has nothing to connect to, and therefore, can't make a trail.
|
||||
if (trailPoints.Count <= 2)
|
||||
return null;
|
||||
|
||||
// If the trail point has any NaN positions, don't draw anything.
|
||||
if (trailPoints.Any(point => point.HasNaNs()))
|
||||
return null;
|
||||
|
||||
// If the trail points are all equal, don't draw anything.
|
||||
if (trailPoints.All(point => point == trailPoints[0]))
|
||||
return null;
|
||||
|
||||
IEnumerable<VertexPosition2DColorTexture> vertices = CreateVerticesRectangleTrail(trailPoints.ToList(), settings);
|
||||
int[] indices = CreateIndicesRectangleTrail(trailPoints.Count);
|
||||
|
||||
// Create the set, and just return it if not asked to render.
|
||||
PrimitiveSet set = new(vertices.ToArray(), indices, settings);
|
||||
if (!render)
|
||||
return set;
|
||||
|
||||
// Else render the set and return it.
|
||||
return set.Render();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Instance Methods
|
||||
/// <summary>
|
||||
/// Renders the provided primitive set to the screen.
|
||||
/// </summary>
|
||||
/// <returns>The provided set.</returns>
|
||||
public PrimitiveSet Render()
|
||||
{
|
||||
PerformPixelationSafetyChecks(Settings);
|
||||
|
||||
if (Indices.Length % 6 != 0 || Vertices.Length <= 3)
|
||||
return this;
|
||||
|
||||
// Perform screen culling, for performance reasons.
|
||||
Main.instance.GraphicsDevice.RasterizerState = RasterizerState.CullNone;
|
||||
Main.instance.GraphicsDevice.RasterizerState.ScissorTestEnable = true;
|
||||
Main.instance.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, Main.screenWidth, Main.screenHeight);
|
||||
|
||||
Matrix view;
|
||||
Matrix projection;
|
||||
if (Settings.Pixelate)
|
||||
CalcuatePixelatedPerspectiveMatrices(out view, out projection);
|
||||
else
|
||||
CalamityUtils.CalculatePerspectiveMatricies(out view, out projection);
|
||||
|
||||
var shaderToUse = Settings.Shader ?? GameShaders.Misc["CalamityMod:StandardPrimitiveShader"];
|
||||
shaderToUse.Shader.Parameters["uWorldViewProjection"].SetValue(view * projection);
|
||||
shaderToUse.Apply();
|
||||
|
||||
// Render the set.
|
||||
Main.instance.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, Vertices, 0, Vertices.Length, Indices, 0, Indices.Length / 3);
|
||||
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
|
||||
return this;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Set Preperation
|
||||
private static IEnumerable<Vector2> PreparePointsRectangleTrail(IEnumerable<Vector2> positions, PrimitiveSettings settings, int pointsToCreate)
|
||||
{
|
||||
// Don't smoothen the points unless explicitly told do so.
|
||||
if (!settings.Smoothen)
|
||||
{
|
||||
List<Vector2> basePoints = positions.Where(originalPosition => originalPosition != Vector2.Zero).ToList();
|
||||
List<Vector2> endPoints = new();
|
||||
|
||||
if (basePoints.Count <= 2)
|
||||
return endPoints;
|
||||
|
||||
// Remap the original positions across a certain length.
|
||||
for (int i = 0; i < pointsToCreate; i++)
|
||||
{
|
||||
float completionRatio = i / (float)(pointsToCreate - 1f);
|
||||
int currentIndex = (int)(completionRatio * (basePoints.Count - 1));
|
||||
Vector2 currentPoint = basePoints[currentIndex];
|
||||
Vector2 nextPoint = basePoints[(currentIndex + 1) % basePoints.Count];
|
||||
endPoints.Add(Vector2.Lerp(currentPoint, nextPoint, completionRatio * (basePoints.Count - 1) % 0.99999f) - Main.screenPosition);
|
||||
}
|
||||
return endPoints;
|
||||
}
|
||||
|
||||
List<Vector2> controlPoints = new();
|
||||
for (int i = 0; i < positions.Count(); i++)
|
||||
{
|
||||
// Don't incorporate points that are zeroed out.
|
||||
// They are almost certainly a result of incomplete oldPos arrays.
|
||||
if (positions.ElementAt(i) == Vector2.Zero)
|
||||
continue;
|
||||
|
||||
float completionRatio = i / (float)positions.Count();
|
||||
Vector2 offset = -Main.screenPosition;
|
||||
if (settings.OffsetFunction != null)
|
||||
offset += settings.OffsetFunction(completionRatio);
|
||||
controlPoints.Add(positions.ElementAt(i) + offset);
|
||||
}
|
||||
List<Vector2> points = new();
|
||||
|
||||
// Avoid stupid index errors.
|
||||
if (controlPoints.Count <= 4)
|
||||
return controlPoints;
|
||||
|
||||
for (int j = 0; j < pointsToCreate; j++)
|
||||
{
|
||||
float splineInterpolant = j / (float)pointsToCreate;
|
||||
float localSplineInterpolant = splineInterpolant * (controlPoints.Count - 1f) % 1f;
|
||||
int localSplineIndex = (int)(splineInterpolant * (controlPoints.Count - 1f));
|
||||
|
||||
Vector2 farLeft;
|
||||
Vector2 left = controlPoints[localSplineIndex];
|
||||
Vector2 right = controlPoints[localSplineIndex + 1];
|
||||
Vector2 farRight;
|
||||
|
||||
// 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];
|
||||
|
||||
points.Add(Vector2.CatmullRom(farLeft, left, right, farRight, localSplineInterpolant));
|
||||
}
|
||||
|
||||
// Manually insert the front and end points.
|
||||
points.Insert(0, controlPoints.First());
|
||||
points.Add(controlPoints.Last());
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
private static IEnumerable<VertexPosition2DColorTexture> CreateVerticesRectangleTrail(List<Vector2> positions, PrimitiveSettings settings)
|
||||
{
|
||||
List<VertexPosition2DColorTexture> vertices = new();
|
||||
|
||||
for (int i = 0; i < positions.Count; i++)
|
||||
{
|
||||
float completionRatio = i / (float)(positions.Count - 1);
|
||||
float widthAtVertex = settings.WidthFunction(completionRatio);
|
||||
Color vertexColor = settings.ColorFunction(completionRatio);
|
||||
Vector2 currentPosition = positions[i];
|
||||
Vector2 directionToAhead = i == positions.Count - 1 ? (positions[i] - positions[i - 1]).SafeNormalize(Vector2.Zero) : (positions[i + 1] - positions[i]).SafeNormalize(Vector2.Zero);
|
||||
|
||||
Vector2 leftCurrentTextureCoord = new(completionRatio, 0f);
|
||||
Vector2 rightCurrentTextureCoord = new(completionRatio, 1f);
|
||||
|
||||
// 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;
|
||||
|
||||
// Override the initial vertex positions if requested.
|
||||
if (i == 0 && settings.InitialVertexPositionsOverride.HasValue && settings.InitialVertexPositionsOverride.Value.Item1 != Vector2.Zero && settings.InitialVertexPositionsOverride.Value.Item2 != Vector2.Zero)
|
||||
{
|
||||
left = settings.InitialVertexPositionsOverride.Value.Item1;
|
||||
right = settings.InitialVertexPositionsOverride.Value.Item2;
|
||||
}
|
||||
|
||||
// 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.
|
||||
vertices.Add(new VertexPosition2DColorTexture(left, vertexColor, leftCurrentTextureCoord));
|
||||
vertices.Add(new VertexPosition2DColorTexture(right, vertexColor, rightCurrentTextureCoord));
|
||||
}
|
||||
|
||||
return vertices;
|
||||
}
|
||||
|
||||
private static int[] CreateIndicesRectangleTrail(int pointCount)
|
||||
{
|
||||
// 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.
|
||||
int totalIndices = (pointCount - 1) * 6;
|
||||
int[] indices = new int[totalIndices];
|
||||
|
||||
for (int i = 0; i < pointCount - 2; i++)
|
||||
{
|
||||
int startingTriangleIndex = i * 6;
|
||||
int connectToIndex = i * 2;
|
||||
indices[startingTriangleIndex] = connectToIndex;
|
||||
indices[startingTriangleIndex + 1] = connectToIndex + 1;
|
||||
indices[startingTriangleIndex + 2] = connectToIndex + 2;
|
||||
indices[startingTriangleIndex + 3] = connectToIndex + 2;
|
||||
indices[startingTriangleIndex + 4] = connectToIndex + 1;
|
||||
indices[startingTriangleIndex + 5] = connectToIndex + 3;
|
||||
}
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
||||
private static void CalcuatePixelatedPerspectiveMatrices(out Matrix viewMatrix, out Matrix projectionMatrix)
|
||||
{
|
||||
// Due to the scaling, the normal transformation calcuations do not work with pixelated primitives.
|
||||
projectionMatrix = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -1, 1);
|
||||
viewMatrix = Matrix.Identity;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer1Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -42,6 +42,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer4Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -51,6 +51,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer4Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -44,6 +44,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer1Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -54,6 +54,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer1Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -56,6 +56,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
NPC.Calamity().canBreakPlayerDefense = true;
|
||||
SpawnModBiomes = new int[2] { ModContent.GetInstance<AbyssLayer3Biome>().Type, ModContent.GetInstance<AbyssLayer4Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -45,6 +45,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer2Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -59,6 +59,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer3Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -49,6 +49,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer3Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
|
||||
@@ -36,6 +36,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.dontCountMe = true;
|
||||
NPC.dontTakeDamage = true;
|
||||
NPC.chaseable = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
|
||||
@@ -36,6 +36,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.dontCountMe = true;
|
||||
NPC.dontTakeDamage = true;
|
||||
NPC.chaseable = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
|
||||
@@ -74,6 +74,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer4Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -36,6 +36,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.dontCountMe = true;
|
||||
NPC.dontTakeDamage = true;
|
||||
NPC.chaseable = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
|
||||
@@ -45,6 +45,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer3Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -43,6 +43,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
|
||||
@@ -43,6 +43,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
|
||||
@@ -64,6 +64,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[2] { ModContent.GetInstance<AbyssLayer3Biome>().Type, ModContent.GetInstance<AbyssLayer4Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -43,6 +43,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
|
||||
@@ -43,6 +43,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[2] { ModContent.GetInstance<AbyssLayer2Biome>().Type, ModContent.GetInstance<AbyssLayer3Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -52,6 +52,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer2Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -55,6 +55,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = false;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer3Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -49,6 +49,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer1Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -40,6 +40,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
|
||||
@@ -59,6 +59,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[2] { ModContent.GetInstance<AbyssLayer2Biome>().Type, ModContent.GetInstance<AbyssLayer3Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -40,6 +40,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
|
||||
@@ -61,10 +61,13 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer4Biome>().Type };
|
||||
|
||||
if (Main.zenithWorld) // legg
|
||||
{
|
||||
NPC.height = (int)(NPC.height * 1.5f);
|
||||
}
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -69,6 +69,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
NPC.GravityIgnoresLiquid = true;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbyssLayer1Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -51,6 +51,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[2] { ModContent.GetInstance<AbyssLayer1Biome>().Type, ModContent.GetInstance<AbyssLayer2Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -50,6 +50,10 @@ namespace CalamityMod.NPCs.Abyss
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[2] { ModContent.GetInstance<AbyssLayer2Biome>().Type, ModContent.GetInstance<AbyssLayer3Biome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -74,6 +74,10 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AcidRainBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
@@ -230,7 +234,7 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
Vector2 tailDrawPosition = segmentPositions[^1] - tailRotation.ToRotationVector2() * 4f;
|
||||
SpriteEffects tailDirection = NPC.velocity.X < 0f ? SpriteEffects.None : SpriteEffects.FlipVertically;
|
||||
Main.EntitySpriteDraw(tailTexture, tailDrawPosition, tailArea, NPC.GetAlpha(Color.White), tailRotation, tailArea.Size() * new Vector2(0f, 0.5f), NPC.scale, tailDirection, 0);
|
||||
PrimitiveSet.Prepare(segmentPositions, new(SegmentWidthFunction, _ => NPC.GetAlpha(Color.White), pixelate: false, shader: GameShaders.Misc["CalamityMod:PrimitiveTexture"]), 36);
|
||||
PrimitiveRenderer.RenderTrail(segmentPositions, new(SegmentWidthFunction, _ => NPC.GetAlpha(Color.White), pixelate: false, shader: GameShaders.Misc["CalamityMod:PrimitiveTexture"]), 36);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -60,6 +60,10 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AcidRainBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -58,6 +58,10 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AcidRainBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
NPC.lifeMax = 220;
|
||||
NPC.defense = 5;
|
||||
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.5f;
|
||||
AnimationType = NPCID.CorruptSlime;
|
||||
AIType = NPCID.ToxicSludge;
|
||||
NPC.value = Item.buyPrice(0, 0, 5, 0);
|
||||
@@ -46,6 +46,10 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AcidRainBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -83,6 +83,10 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AcidRainBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -71,6 +71,10 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AcidRainBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
NPC.defense = 10;
|
||||
}
|
||||
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.8f;
|
||||
NPC.value = Item.buyPrice(0, 0, 5, 0);
|
||||
NPC.lavaImmune = false;
|
||||
NPC.noGravity = false;
|
||||
@@ -56,6 +56,10 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AcidRainBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -69,6 +69,10 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AcidRainBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -66,6 +66,10 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AcidRainBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer) => writer.Write(Flying);
|
||||
|
||||
@@ -62,6 +62,10 @@ namespace CalamityMod.NPCs.AcidRain
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
NPC.Calamity().VulnerableToWater = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AcidRainBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -51,6 +51,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbovegroundAstralBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -46,6 +46,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbovegroundAstralBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.aiStyle = NPCAIStyleID.Slime;
|
||||
NPC.defense = 8;
|
||||
NPC.lifeMax = 200;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.6f;
|
||||
NPC.value = Item.buyPrice(0, 0, 10, 0);
|
||||
NPC.alpha = 60;
|
||||
NPC.HitSound = SoundID.NPCHit1;
|
||||
@@ -45,6 +45,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbovegroundAstralBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -52,6 +52,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
}
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
|
||||
@@ -59,6 +59,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<UndergroundAstralBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -154,6 +154,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbovegroundAstralBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -76,6 +76,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbovegroundAstralDesertBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public static bool ValidMovementPosition(Tile tile)
|
||||
|
||||
@@ -59,6 +59,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbovegroundAstralDesertBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -55,6 +55,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
{
|
||||
NPC.scale = 3f;
|
||||
}
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -51,6 +51,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<UndergroundAstralBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -61,6 +61,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbovegroundAstralBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -82,6 +82,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbovegroundAstralBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -60,6 +60,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbovegroundAstralBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -62,6 +62,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<AbovegroundAstralBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -60,6 +60,10 @@ namespace CalamityMod.NPCs.Astral
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<UndergroundAstralBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental
|
||||
NPC.defense = 0;
|
||||
NPC.DR_NERD(normalDR);
|
||||
NPC.lifeMax = 1000;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.5f;
|
||||
NPC.noGravity = true;
|
||||
NPC.noTileCollide = true;
|
||||
NPC.canGhostHeal = false;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.Bumblebirb
|
||||
NPC.LifeMaxNERB(9375, 11250, 5000); // Old HP - 12000, 15000
|
||||
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
|
||||
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.15f;
|
||||
NPC.lavaImmune = true;
|
||||
NPC.noTileCollide = true;
|
||||
NPC.noGravity = true;
|
||||
@@ -45,6 +45,10 @@ namespace CalamityMod.NPCs.Bumblebirb
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
|
||||
@@ -49,6 +49,10 @@ namespace CalamityMod.NPCs.CalClone
|
||||
NPC.Calamity().VulnerableToHeat = false;
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToWater = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
+38
-10
@@ -158,6 +158,14 @@ namespace CalamityMod.NPCs
|
||||
// Used to nerf desert prehardmode enemies pre-Desert Scourge
|
||||
private const double DesertEnemyStatMultiplier = 0.75;
|
||||
|
||||
// Used to nerf Master Mode enemies
|
||||
public const double MasterModeEnemyHPMultiplier = 0.75;
|
||||
public const double MasterModeEnemyDamageMultiplier = 0.85;
|
||||
|
||||
// Used to nerf Expert and Master Mode enemies
|
||||
public const float ExpertModeEnemyKnockbackMultiplier = 0.05f;
|
||||
public const float MasterModeEnemyKnockbackMultiplier = 0.1f;
|
||||
|
||||
// Used to increase coin drops in Normal Mode
|
||||
private const double NPCValueMultiplier_NormalCalamity = 1.5;
|
||||
|
||||
@@ -2485,14 +2493,7 @@ namespace CalamityMod.NPCs
|
||||
|
||||
// Nerf KB resist in Expert and Master using this roundabout method
|
||||
if (Main.expertMode)
|
||||
{
|
||||
if (npc.knockBackResist > 0f && npc.knockBackResist < 1f)
|
||||
{
|
||||
float knockBackResistMult = Main.masterMode ? 0.1f : 0.05f;
|
||||
float knockBackResistReduction = MathHelper.Clamp((1f - npc.knockBackResist) * knockBackResistMult, 0f, npc.knockBackResist - 0.01f);
|
||||
npc.knockBackResist -= knockBackResistReduction;
|
||||
}
|
||||
}
|
||||
AdjustExpertModeStatScaling(npc);
|
||||
|
||||
// Nerf a shitload of Master Mode enemies
|
||||
// HP is nerfed by 25% (this nerf is higher due to the player not dealing any more damage in Master)
|
||||
@@ -2991,8 +2992,9 @@ namespace CalamityMod.NPCs
|
||||
case NPCID.DD2WyvernT1:
|
||||
case NPCID.DD2WyvernT2:
|
||||
case NPCID.DD2WyvernT3:
|
||||
npc.lifeMax = (int)(npc.lifeMax * 0.75);
|
||||
npc.damage = (int)(npc.damage * 0.85);
|
||||
case NPCID.AncientCultistSquidhead:
|
||||
case NPCID.SlimeSpiked:
|
||||
AdjustMasterModeStatScaling(npc);
|
||||
npc.defDamage = npc.damage;
|
||||
break;
|
||||
}
|
||||
@@ -7714,5 +7716,31 @@ namespace CalamityMod.NPCs
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Adjust Difficulty Stat Scaling
|
||||
// Adjust HP and damage in Master Mode
|
||||
public static void AdjustMasterModeStatScaling(NPC npc)
|
||||
{
|
||||
if (!Main.masterMode)
|
||||
return;
|
||||
|
||||
npc.lifeMax = (int)(npc.lifeMax * MasterModeEnemyHPMultiplier);
|
||||
npc.damage = (int)(npc.damage * MasterModeEnemyDamageMultiplier);
|
||||
}
|
||||
|
||||
// Adjust only knockback resist in Expert Mode (this is also adjusted in Master Mode because Expert has to be enabled if Master is enabled)
|
||||
public static void AdjustExpertModeStatScaling(NPC npc)
|
||||
{
|
||||
if (!Main.expertMode)
|
||||
return;
|
||||
|
||||
if (npc.knockBackResist <= 0f || npc.knockBackResist >= 1f)
|
||||
return;
|
||||
|
||||
float knockBackResistMult = Main.masterMode ? MasterModeEnemyKnockbackMultiplier : ExpertModeEnemyKnockbackMultiplier;
|
||||
float knockBackResistReduction = MathHelper.Clamp((1f - npc.knockBackResist) * knockBackResistMult, 0f, npc.knockBackResist - 0.01f);
|
||||
npc.knockBackResist -= knockBackResistReduction;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -242,6 +242,7 @@ namespace CalamityMod.NPCs
|
||||
"Kiriku", // <@!395312478160027668> (rulosss#6814)
|
||||
"Lacuna", // <@!790746689211203604> (_lacuna_)
|
||||
"Mae Borowski", //<@!219158690433990656> (justakkolite)
|
||||
"Jackie", // <@!353241811717718016> (jackalchan)
|
||||
};
|
||||
|
||||
// The following sets are for the 1.4 Town Pets: Town Dogs, Cats and Bunnies.
|
||||
|
||||
@@ -54,6 +54,10 @@ namespace CalamityMod.NPCs.CeaselessVoid
|
||||
NPC.HitSound = SoundID.NPCHit53;
|
||||
NPC.DeathSound = SoundID.NPCDeath44;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -46,6 +46,10 @@ namespace CalamityMod.NPCs.Crabulon
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void FindFrame(int frameHeight)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.Crags
|
||||
NPC.height = 30;
|
||||
NPC.defense = 12;
|
||||
NPC.lifeMax = 140;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.75f;
|
||||
AnimationType = NPCID.DemonEye;
|
||||
NPC.value = Item.buyPrice(0, 0, 5, 0);
|
||||
NPC.HitSound = SoundID.NPCHit1;
|
||||
@@ -47,6 +47,10 @@ namespace CalamityMod.NPCs.Crags
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToWater = true;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<BrimstoneCragsBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.Crags
|
||||
NPC.defense = 38;
|
||||
NPC.DR_NERD(0.35f);
|
||||
NPC.lifeMax = 120;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.1f;
|
||||
NPC.value = Item.buyPrice(0, 0, 5, 0);
|
||||
NPC.HitSound = SoundID.NPCHit41;
|
||||
NPC.DeathSound = SoundID.NPCDeath14;
|
||||
@@ -55,6 +55,10 @@ namespace CalamityMod.NPCs.Crags
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToWater = true;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<BrimstoneCragsBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -44,6 +44,10 @@ namespace CalamityMod.NPCs.Crags
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToWater = true;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<BrimstoneCragsBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace CalamityMod.NPCs.Crags
|
||||
NPC.height = 30;
|
||||
NPC.defense = 10;
|
||||
NPC.lifeMax = 250;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.5f;
|
||||
AnimationType = NPCID.CorruptSlime;
|
||||
NPC.value = Item.buyPrice(0, 0, 5, 0);
|
||||
NPC.alpha = 50;
|
||||
@@ -48,6 +48,10 @@ namespace CalamityMod.NPCs.Crags
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToWater = true;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<BrimstoneCragsBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -45,6 +45,10 @@ namespace CalamityMod.NPCs.Crags
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
NPC.Calamity().VulnerableToWater = true;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<BrimstoneCragsBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -53,6 +53,10 @@ namespace CalamityMod.NPCs.Crags
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToWater = true;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<BrimstoneCragsBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -43,6 +43,10 @@ namespace CalamityMod.NPCs.Crags
|
||||
NPC.Calamity().VulnerableToHeat = false;
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToWater = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
|
||||
@@ -52,6 +52,10 @@ namespace CalamityMod.NPCs.Crags
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToWater = true;
|
||||
SpawnModBiomes = new int[1] { ModContent.GetInstance<BrimstoneCragsBiome>().Type };
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -45,6 +45,10 @@ namespace CalamityMod.NPCs.DevourerofGods
|
||||
NPC.DeathSound = SoundID.NPCDeath14;
|
||||
NPC.netAlways = true;
|
||||
NPC.dontCountMe = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
|
||||
@@ -58,6 +58,10 @@ namespace CalamityMod.NPCs.DevourerofGods
|
||||
NPC.HitSound = SoundID.NPCHit4;
|
||||
NPC.DeathSound = SoundID.NPCDeath14;
|
||||
NPC.netAlways = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -42,6 +42,10 @@ namespace CalamityMod.NPCs.DevourerofGods
|
||||
NPC.DeathSound = SoundID.NPCDeath14;
|
||||
NPC.netAlways = true;
|
||||
NPC.dontCountMe = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SendExtraAI(BinaryWriter writer)
|
||||
|
||||
@@ -402,7 +402,7 @@ namespace CalamityMod.NPCs.DevourerofGods
|
||||
if (hitboxBotRight < minDist)
|
||||
minDist = hitboxBotRight;
|
||||
|
||||
return minDist <= (phase2Started ? 70f : 35f) * NPC.scale && NPC.Opacity >= 1f;
|
||||
return minDist <= (phase2Started ? 70f : 35f) * NPC.scale && NPC.Opacity >= 1f && invinceTime <= 0;
|
||||
}
|
||||
|
||||
public override void HitEffect(NPC.HitInfo hit)
|
||||
|
||||
@@ -949,6 +949,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
|
||||
// Fly to the right of the target
|
||||
case (int)Phase.Normal:
|
||||
|
||||
// Avoid cheap bullshit
|
||||
NPC.damage = 0;
|
||||
|
||||
// Smooth movement towards the location Apollo is meant to be at
|
||||
CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, 0f, false);
|
||||
|
||||
@@ -1022,6 +1025,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
|
||||
// Charge
|
||||
case (int)Phase.RocketBarrage:
|
||||
|
||||
// Avoid cheap bullshit
|
||||
NPC.damage = 0;
|
||||
|
||||
// Smooth movement towards the location Apollo is meant to be at
|
||||
CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, 0f, false);
|
||||
|
||||
@@ -1063,6 +1069,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
|
||||
// Create telegraph beams between the charge location array positions
|
||||
case (int)Phase.LineUpChargeCombo:
|
||||
|
||||
// Avoid cheap bullshit
|
||||
NPC.damage = 0;
|
||||
|
||||
if (!readyToCharge)
|
||||
{
|
||||
// Smooth movement towards the location Apollo is meant to be at
|
||||
@@ -1124,6 +1133,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
|
||||
calamityGlobalNPC.newAI[2] += 1f;
|
||||
if (calamityGlobalNPC.newAI[2] >= timeToLineUpCharge)
|
||||
{
|
||||
// Set damage
|
||||
NPC.damage = NPC.defDamage;
|
||||
|
||||
ExoMechsSky.CreateLightningBolt(10);
|
||||
|
||||
AIState = (float)Phase.ChargeCombo;
|
||||
@@ -1137,6 +1149,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
|
||||
// Charge to several locations almost instantly (Apollo doesn't teleport here, he's just moving very fast :D)
|
||||
case (int)Phase.ChargeCombo:
|
||||
|
||||
// Set damage
|
||||
NPC.damage = NPC.defDamage;
|
||||
|
||||
// Tell Artemis to not fire lasers for a short time
|
||||
NPC.ai[3] = 61f;
|
||||
|
||||
@@ -1240,6 +1255,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
|
||||
// Reset phase and variables
|
||||
if (calamityGlobalNPC.newAI[2] >= maxCharges - 1)
|
||||
{
|
||||
// Avoid cheap bullshit
|
||||
NPC.damage = 0;
|
||||
|
||||
if (Main.zenithWorld && !exoMechdusa)
|
||||
{
|
||||
pickNewLocation = NPC.localAI[2] == 0f;
|
||||
@@ -1277,6 +1295,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
|
||||
// Phase transition animation, that's all this exists for
|
||||
case (int)Phase.PhaseTransition:
|
||||
|
||||
// Avoid cheap bullshit
|
||||
NPC.damage = 0;
|
||||
|
||||
// Smooth movement towards the location Apollo is meant to be at
|
||||
CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, 0f, false);
|
||||
|
||||
@@ -1360,7 +1381,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
|
||||
if (hitboxBotRight < minDist)
|
||||
minDist = hitboxBotRight;
|
||||
|
||||
return minDist <= 100f && NPC.Opacity == 1f && AIState == (float)Phase.ChargeCombo;
|
||||
return minDist <= 100f && NPC.Opacity == 1f;
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
@@ -1553,7 +1574,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
|
||||
|
||||
currentSegmentRotation += segmentRotationOffset;
|
||||
}
|
||||
PrimitiveSet.Prepare(ribbonDrawPositions, new(RibbonTrailWidthFunction, RibbonTrailColorFunction), 66);
|
||||
PrimitiveRenderer.RenderTrail(ribbonDrawPositions, new(RibbonTrailWidthFunction, RibbonTrailColorFunction), 66);
|
||||
}
|
||||
|
||||
int instanceCount = (int)MathHelper.Lerp(1f, 15f, ChargeComboFlash);
|
||||
@@ -1618,11 +1639,11 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 8f;
|
||||
PrimitiveSet.Prepare(drawPositions, new(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, (_) => drawOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70);
|
||||
PrimitiveRenderer.RenderTrail(drawPositions, new(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, (_) => drawOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70);
|
||||
}
|
||||
}
|
||||
else
|
||||
PrimitiveSet.Prepare(drawPositions, new(FlameTrailWidthFunction, FlameTrailColorFunction, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70);
|
||||
PrimitiveRenderer.RenderTrail(drawPositions, new(FlameTrailWidthFunction, FlameTrailColorFunction, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1328,13 +1328,13 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
|
||||
if (NPC.Opacity > 0f && !NPC.IsABestiaryIconDummy)
|
||||
{
|
||||
List<Vector2> arm2ElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(armSegmentDrawPosition, arm2DrawPosition + arm2Rotation.ToRotationVector2() * -direction * 20f, 250290787);
|
||||
PrimitiveSet.Prepare(arm2ElectricArcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
|
||||
PrimitiveSet.Prepare(arm2ElectricArcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
|
||||
PrimitiveRenderer.RenderTrail(arm2ElectricArcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
|
||||
PrimitiveRenderer.RenderTrail(arm2ElectricArcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
|
||||
|
||||
// Draw electricity between the final arm and the hand.
|
||||
List<Vector2> handElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(arm2DrawPosition - arm2Rotation.ToRotationVector2() * direction * 100f, handPosition, 27182);
|
||||
PrimitiveSet.Prepare(handElectricArcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
|
||||
PrimitiveSet.Prepare(handElectricArcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
|
||||
PrimitiveRenderer.RenderTrail(handElectricArcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
|
||||
PrimitiveRenderer.RenderTrail(handElectricArcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
|
||||
}
|
||||
|
||||
shoulderDrawPosition += Vector2.UnitY * NPC.gfxOffY - screenOffset;
|
||||
@@ -1390,13 +1390,13 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
|
||||
if (NPC.Opacity > 0f && !NPC.IsABestiaryIconDummy)
|
||||
{
|
||||
List<Vector2> arm2ElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(arm1DrawPosition - arm2Rotation.ToRotationVector2() * direction * 10f, arm1DrawPosition + arm2Rotation.ToRotationVector2() * direction * 20f, 31416);
|
||||
PrimitiveSet.Prepare(arm2ElectricArcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
|
||||
PrimitiveSet.Prepare(arm2ElectricArcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
|
||||
PrimitiveRenderer.RenderTrail(arm2ElectricArcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
|
||||
PrimitiveRenderer.RenderTrail(arm2ElectricArcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
|
||||
|
||||
// Draw electricity between the final arm and the hand.
|
||||
List<Vector2> handElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(arm2DrawPosition - arm2Rotation.ToRotationVector2() * direction * 20f, handPosition, 27182);
|
||||
PrimitiveSet.Prepare(handElectricArcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
|
||||
PrimitiveSet.Prepare(handElectricArcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
|
||||
PrimitiveRenderer.RenderTrail(handElectricArcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
|
||||
PrimitiveRenderer.RenderTrail(handElectricArcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
|
||||
}
|
||||
|
||||
shoulderDrawPosition += Vector2.UnitY * NPC.gfxOffY - screenOffset;
|
||||
|
||||
@@ -724,6 +724,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
|
||||
// Fly to the left of the target
|
||||
case (int)Phase.Normal:
|
||||
|
||||
// Avoid cheap bullshit
|
||||
NPC.damage = 0;
|
||||
|
||||
if (!stopRotatingAndSlowDown)
|
||||
{
|
||||
// Set charge variable to default
|
||||
@@ -859,6 +862,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set damage
|
||||
NPC.damage = NPC.defDamage;
|
||||
|
||||
// Charge until a certain distance is reached and then return to normal phase
|
||||
SoundEngine.PlaySound(ChargeSound, NPC.Center);
|
||||
AIState = (float)Phase.Charge;
|
||||
@@ -877,6 +883,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
|
||||
// Charge
|
||||
case (int)Phase.Charge:
|
||||
|
||||
// Set damage
|
||||
NPC.damage = NPC.defDamage;
|
||||
|
||||
// Allow the charge flash to happen
|
||||
shouldDoChargeFlash = true;
|
||||
|
||||
@@ -884,6 +893,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
|
||||
calamityGlobalNPC.newAI[2] += 1f;
|
||||
if (calamityGlobalNPC.newAI[2] >= chargeDuration)
|
||||
{
|
||||
// Avoid cheap bullshit
|
||||
NPC.damage = 0;
|
||||
|
||||
// Decelerate
|
||||
NPC.velocity *= decelerationVelocityMult;
|
||||
|
||||
@@ -901,6 +913,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
|
||||
// Laser shotgun barrage
|
||||
case (int)Phase.LaserShotgun:
|
||||
|
||||
// Avoid cheap bullshit
|
||||
NPC.damage = 0;
|
||||
|
||||
// Smooth movement towards the location Artemis is meant to be at
|
||||
CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, 0f, false);
|
||||
|
||||
@@ -961,6 +976,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
|
||||
// Fly above target, fire deathray and move in a circle around the target
|
||||
case (int)Phase.Deathray:
|
||||
|
||||
// Avoid cheap bullshit
|
||||
NPC.damage = 0;
|
||||
|
||||
// Fly above, stop doing this if in the proper position
|
||||
// Stop rotating and spin around a target point
|
||||
if ((destination - NPC.Center).Length() < spinLocationDistance || calamityGlobalNPC.newAI[2] > 0f)
|
||||
@@ -1178,6 +1196,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
|
||||
// Phase transition animation, that's all this exists for
|
||||
case (int)Phase.PhaseTransition:
|
||||
|
||||
// Avoid cheap bullshit
|
||||
NPC.damage = 0;
|
||||
|
||||
// Smooth movement towards the location Artemis is meant to be at
|
||||
CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, 0f, false);
|
||||
|
||||
@@ -1255,7 +1276,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
|
||||
if (hitboxBotRight < minDist)
|
||||
minDist = hitboxBotRight;
|
||||
|
||||
return minDist <= 100f && NPC.Opacity == 1f && AIState == (float)Phase.Charge;
|
||||
return minDist <= 100f && NPC.Opacity == 1f;
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
@@ -1448,7 +1469,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
|
||||
|
||||
currentSegmentRotation += segmentRotationOffset;
|
||||
}
|
||||
PrimitiveSet.Prepare(ribbonDrawPositions, new(RibbonTrailWidthFunction, RibbonTrailColorFunction), 66);
|
||||
PrimitiveRenderer.RenderTrail(ribbonDrawPositions, new(RibbonTrailWidthFunction, RibbonTrailColorFunction), 66);
|
||||
}
|
||||
|
||||
int instanceCount = (int)MathHelper.Lerp(1f, 15f, ChargeFlash);
|
||||
@@ -1513,11 +1534,11 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 8f;
|
||||
PrimitiveSet.Prepare(drawPositions, new(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, (_) => drawOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70);
|
||||
PrimitiveRenderer.RenderTrail(drawPositions, new(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, (_) => drawOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70);
|
||||
}
|
||||
}
|
||||
else
|
||||
PrimitiveSet.Prepare(drawPositions, new(FlameTrailWidthFunction, FlameTrailColorFunction, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70);
|
||||
PrimitiveRenderer.RenderTrail(drawPositions, new(FlameTrailWidthFunction, FlameTrailColorFunction, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
// Set vulnerable to false by default
|
||||
vulnerable = false;
|
||||
|
||||
CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)NPC.ai[2]].Calamity();
|
||||
NPC head = Main.npc[(int)NPC.ai[2]];
|
||||
CalamityGlobalNPC calamityGlobalNPC_Head = head.Calamity();
|
||||
|
||||
bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune;
|
||||
NPC.dontTakeDamage = Main.npc[(int)NPC.ai[2]].dontTakeDamage;
|
||||
@@ -470,7 +471,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
|
||||
SmokeDrawer.Update();
|
||||
|
||||
Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target];
|
||||
Player player = Main.player[head.target];
|
||||
|
||||
Vector2 npcCenter = NPC.Center;
|
||||
float targetCenterX = player.Center.X;
|
||||
@@ -482,31 +483,72 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
targetCenterX -= npcCenter.X;
|
||||
targetCenterY -= npcCenter.Y;
|
||||
|
||||
float distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
|
||||
float newPosition = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
|
||||
if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length)
|
||||
{
|
||||
try
|
||||
{
|
||||
npcCenter = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
|
||||
targetCenterX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - npcCenter.X;
|
||||
targetCenterY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - npcCenter.Y;
|
||||
npcCenter = NPC.Center;
|
||||
targetCenterX = Main.npc[(int)NPC.ai[1]].Center.X - npcCenter.X;
|
||||
targetCenterY = Main.npc[(int)NPC.ai[1]].Center.Y - npcCenter.Y;
|
||||
}
|
||||
catch { }
|
||||
|
||||
NPC.rotation = (float)Math.Atan2(targetCenterY, targetCenterX) + MathHelper.PiOver2;
|
||||
distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
|
||||
distanceFromTarget = (distanceFromTarget - NPC.width) / distanceFromTarget;
|
||||
targetCenterX *= distanceFromTarget;
|
||||
targetCenterY *= distanceFromTarget;
|
||||
newPosition = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
|
||||
newPosition = (newPosition - NPC.width) / newPosition;
|
||||
targetCenterX *= newPosition;
|
||||
targetCenterY *= newPosition;
|
||||
NPC.velocity = Vector2.Zero;
|
||||
NPC.position.X = NPC.position.X + targetCenterX;
|
||||
NPC.position.Y = NPC.position.Y + targetCenterY;
|
||||
NPC.position.X += targetCenterX;
|
||||
NPC.position.Y += targetCenterY;
|
||||
|
||||
if (targetCenterX < 0f)
|
||||
NPC.spriteDirection = -1;
|
||||
else if (targetCenterX > 0f)
|
||||
NPC.spriteDirection = 1;
|
||||
}
|
||||
|
||||
bool speedUp = head.localAI[3] < 180f;
|
||||
|
||||
// Distance from target
|
||||
float distanceFromTarget = Vector2.Distance(head.Center, speedUp ? (player.Center + new Vector2(0f, 2400f)) : player.Center);
|
||||
|
||||
// Increase speed if too far from target
|
||||
float increaseSpeedMult = 1f;
|
||||
float increaseSpeedGateValue = 600f;
|
||||
if (distanceFromTarget > increaseSpeedGateValue)
|
||||
{
|
||||
float distanceAmount = MathHelper.Clamp((distanceFromTarget - increaseSpeedGateValue) / (CalamityGlobalNPC.CatchUpDistance350Tiles - increaseSpeedGateValue), 0f, 1f);
|
||||
increaseSpeedMult = MathHelper.Lerp(1f, 3.5f, distanceAmount);
|
||||
}
|
||||
|
||||
// Velocity and turn speed values
|
||||
float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (bossRush ? 1.25f : death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f);
|
||||
float baseVelocity = 10f * baseVelocityMult;
|
||||
|
||||
// Increase top velocity if target is dead or if Thanatos is uncoiling
|
||||
if (player.dead || speedUp)
|
||||
baseVelocity *= 4f;
|
||||
else
|
||||
baseVelocity *= increaseSpeedMult;
|
||||
|
||||
if (Main.getGoodWorld)
|
||||
baseVelocity *= 1.15f;
|
||||
|
||||
// Calculate contact damage based on velocity
|
||||
float minimalContactDamageVelocity = baseVelocity * 0.25f;
|
||||
float minimalDamageVelocity = baseVelocity * 0.5f;
|
||||
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
|
||||
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
|
||||
{
|
||||
NPC.damage = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
|
||||
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
|
||||
|
||||
@@ -167,7 +167,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
// Set vulnerable to false by default
|
||||
vulnerable = false;
|
||||
|
||||
CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)NPC.ai[2]].Calamity();
|
||||
NPC head = Main.npc[(int)NPC.ai[2]];
|
||||
CalamityGlobalNPC calamityGlobalNPC_Head = head.Calamity();
|
||||
|
||||
bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune;
|
||||
NPC.dontTakeDamage = Main.npc[(int)NPC.ai[2]].dontTakeDamage;
|
||||
@@ -470,7 +471,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
|
||||
SmokeDrawer.Update();
|
||||
|
||||
Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target];
|
||||
Player player = Main.player[head.target];
|
||||
|
||||
Vector2 npcCenter = NPC.Center;
|
||||
float targetCenterX = player.Center.X;
|
||||
@@ -482,33 +483,74 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
targetCenterX -= npcCenter.X;
|
||||
targetCenterY -= npcCenter.Y;
|
||||
|
||||
float distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
|
||||
float newPosition = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
|
||||
if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length)
|
||||
{
|
||||
try
|
||||
{
|
||||
npcCenter = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
|
||||
targetCenterX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - npcCenter.X;
|
||||
targetCenterY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - npcCenter.Y;
|
||||
npcCenter = NPC.Center;
|
||||
targetCenterX = Main.npc[(int)NPC.ai[1]].Center.X - npcCenter.X;
|
||||
targetCenterY = Main.npc[(int)NPC.ai[1]].Center.Y - npcCenter.Y;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
NPC.rotation = (float)Math.Atan2(targetCenterY, targetCenterX) + MathHelper.PiOver2;
|
||||
distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
|
||||
distanceFromTarget = (distanceFromTarget - NPC.width) / distanceFromTarget;
|
||||
targetCenterX *= distanceFromTarget;
|
||||
targetCenterY *= distanceFromTarget;
|
||||
newPosition = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
|
||||
newPosition = (newPosition - NPC.width) / newPosition;
|
||||
targetCenterX *= newPosition;
|
||||
targetCenterY *= newPosition;
|
||||
NPC.velocity = Vector2.Zero;
|
||||
NPC.position.X = NPC.position.X + targetCenterX;
|
||||
NPC.position.Y = NPC.position.Y + targetCenterY;
|
||||
NPC.position.X += targetCenterX;
|
||||
NPC.position.Y += targetCenterY;
|
||||
|
||||
if (targetCenterX < 0f)
|
||||
NPC.spriteDirection = -1;
|
||||
else if (targetCenterX > 0f)
|
||||
NPC.spriteDirection = 1;
|
||||
}
|
||||
|
||||
bool speedUp = head.localAI[3] < 180f;
|
||||
|
||||
// Distance from target
|
||||
float distanceFromTarget = Vector2.Distance(head.Center, speedUp ? (player.Center + new Vector2(0f, 2400f)) : player.Center);
|
||||
|
||||
// Increase speed if too far from target
|
||||
float increaseSpeedMult = 1f;
|
||||
float increaseSpeedGateValue = 600f;
|
||||
if (distanceFromTarget > increaseSpeedGateValue)
|
||||
{
|
||||
float distanceAmount = MathHelper.Clamp((distanceFromTarget - increaseSpeedGateValue) / (CalamityGlobalNPC.CatchUpDistance350Tiles - increaseSpeedGateValue), 0f, 1f);
|
||||
increaseSpeedMult = MathHelper.Lerp(1f, 3.5f, distanceAmount);
|
||||
}
|
||||
|
||||
// Velocity and turn speed values
|
||||
float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (bossRush ? 1.25f : death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f);
|
||||
float baseVelocity = 10f * baseVelocityMult;
|
||||
|
||||
// Increase top velocity if target is dead or if Thanatos is uncoiling
|
||||
if (player.dead || speedUp)
|
||||
baseVelocity *= 4f;
|
||||
else
|
||||
baseVelocity *= increaseSpeedMult;
|
||||
|
||||
if (Main.getGoodWorld)
|
||||
baseVelocity *= 1.15f;
|
||||
|
||||
// Calculate contact damage based on velocity
|
||||
float minimalContactDamageVelocity = baseVelocity * 0.25f;
|
||||
float minimalDamageVelocity = baseVelocity * 0.5f;
|
||||
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
|
||||
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
|
||||
{
|
||||
NPC.damage = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
|
||||
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
|
||||
|
||||
@@ -1010,6 +1010,19 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate contact damage based on velocity
|
||||
float minimalContactDamageVelocity = baseVelocity * 0.25f;
|
||||
float minimalDamageVelocity = baseVelocity * 0.5f;
|
||||
if (NPC.velocity.Length() <= minimalContactDamageVelocity)
|
||||
{
|
||||
NPC.damage = (int)(NPC.defDamage * 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
|
||||
NPC.damage = (int)MathHelper.Lerp(NPC.defDamage * 0.5f, NPC.defDamage, velocityDamageScalar);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
|
||||
|
||||
@@ -167,7 +167,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
// Set vulnerable to false by default
|
||||
vulnerable = false;
|
||||
|
||||
CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)NPC.ai[2]].Calamity();
|
||||
NPC head = Main.npc[(int)NPC.ai[2]];
|
||||
CalamityGlobalNPC calamityGlobalNPC_Head = head.Calamity();
|
||||
|
||||
bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune;
|
||||
NPC.dontTakeDamage = Main.npc[(int)NPC.ai[2]].dontTakeDamage;
|
||||
@@ -468,7 +469,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
|
||||
SmokeDrawer.Update();
|
||||
|
||||
Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target];
|
||||
Player player = Main.player[head.target];
|
||||
|
||||
Vector2 npcCenter = NPC.Center;
|
||||
float targetCenterX = player.Center.X;
|
||||
@@ -480,33 +481,74 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
|
||||
targetCenterX -= npcCenter.X;
|
||||
targetCenterY -= npcCenter.Y;
|
||||
|
||||
float distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
|
||||
float newPosition = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
|
||||
if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length)
|
||||
{
|
||||
try
|
||||
{
|
||||
npcCenter = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
|
||||
targetCenterX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - npcCenter.X;
|
||||
targetCenterY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - npcCenter.Y;
|
||||
npcCenter = NPC.Center;
|
||||
targetCenterX = Main.npc[(int)NPC.ai[1]].Center.X - npcCenter.X;
|
||||
targetCenterY = Main.npc[(int)NPC.ai[1]].Center.Y - npcCenter.Y;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
NPC.rotation = (float)Math.Atan2(targetCenterY, targetCenterX) + MathHelper.PiOver2;
|
||||
distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
|
||||
distanceFromTarget = (distanceFromTarget - NPC.width) / distanceFromTarget;
|
||||
targetCenterX *= distanceFromTarget;
|
||||
targetCenterY *= distanceFromTarget;
|
||||
newPosition = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
|
||||
newPosition = (newPosition - NPC.width) / newPosition;
|
||||
targetCenterX *= newPosition;
|
||||
targetCenterY *= newPosition;
|
||||
NPC.velocity = Vector2.Zero;
|
||||
NPC.position.X = NPC.position.X + targetCenterX;
|
||||
NPC.position.Y = NPC.position.Y + targetCenterY;
|
||||
NPC.position.X += targetCenterX;
|
||||
NPC.position.Y += targetCenterY;
|
||||
|
||||
if (targetCenterX < 0f)
|
||||
NPC.spriteDirection = -1;
|
||||
else if (targetCenterX > 0f)
|
||||
NPC.spriteDirection = 1;
|
||||
}
|
||||
|
||||
bool speedUp = head.localAI[3] < 180f;
|
||||
|
||||
// Distance from target
|
||||
float distanceFromTarget = Vector2.Distance(head.Center, speedUp ? (player.Center + new Vector2(0f, 2400f)) : player.Center);
|
||||
|
||||
// Increase speed if too far from target
|
||||
float increaseSpeedMult = 1f;
|
||||
float increaseSpeedGateValue = 600f;
|
||||
if (distanceFromTarget > increaseSpeedGateValue)
|
||||
{
|
||||
float distanceAmount = MathHelper.Clamp((distanceFromTarget - increaseSpeedGateValue) / (CalamityGlobalNPC.CatchUpDistance350Tiles - increaseSpeedGateValue), 0f, 1f);
|
||||
increaseSpeedMult = MathHelper.Lerp(1f, 3.5f, distanceAmount);
|
||||
}
|
||||
|
||||
// Velocity and turn speed values
|
||||
float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (bossRush ? 1.25f : death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f);
|
||||
float baseVelocity = 10f * baseVelocityMult;
|
||||
|
||||
// Increase top velocity if target is dead or if Thanatos is uncoiling
|
||||
if (player.dead || speedUp)
|
||||
baseVelocity *= 4f;
|
||||
else
|
||||
baseVelocity *= increaseSpeedMult;
|
||||
|
||||
if (Main.getGoodWorld)
|
||||
baseVelocity *= 1.15f;
|
||||
|
||||
// Calculate contact damage based on velocity
|
||||
float minimalContactDamageVelocity = baseVelocity * 0.25f;
|
||||
float minimalDamageVelocity = baseVelocity * 0.5f;
|
||||
float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length();
|
||||
if (bodyAndTailVelocity <= minimalContactDamageVelocity)
|
||||
{
|
||||
NPC.damage = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f);
|
||||
NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
|
||||
|
||||
@@ -48,6 +48,10 @@ namespace CalamityMod.NPCs.HiveMind
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.HiveMind
|
||||
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
|
||||
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
|
||||
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.9f;
|
||||
AIType = -1;
|
||||
NPC.noGravity = true;
|
||||
NPC.noTileCollide = true;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace CalamityMod.NPCs.HiveMind
|
||||
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
|
||||
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
|
||||
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.9f;
|
||||
AIType = -1;
|
||||
NPC.noGravity = true;
|
||||
NPC.noTileCollide = true;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.Leviathan
|
||||
}
|
||||
double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01;
|
||||
NPC.lifeMax += (int)(NPC.lifeMax * HPBoost);
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.2f;
|
||||
NPC.noGravity = true;
|
||||
NPC.noTileCollide = true;
|
||||
NPC.canGhostHeal = false;
|
||||
@@ -51,6 +51,10 @@ namespace CalamityMod.NPCs.Leviathan
|
||||
|
||||
if (Main.getGoodWorld)
|
||||
NPC.scale *= 1.3f;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
NPC.height = 30;
|
||||
NPC.defense = 6;
|
||||
NPC.lifeMax = 50;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.8f;
|
||||
AnimationType = NPCID.Slimer;
|
||||
NPC.value = Item.buyPrice(0, 0, 1, 0);
|
||||
NPC.alpha = 50;
|
||||
@@ -41,6 +41,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
BannerItem = ModContent.ItemType<AeroSlimeBanner>();
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -40,6 +40,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
BannerItem = ModContent.ItemType<ArmoredDiggerBanner>();
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
|
||||
@@ -54,6 +54,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
BannerItem = ModContent.ItemType<ArmoredDiggerBanner>();
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -39,6 +39,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
BannerItem = ModContent.ItemType<ArmoredDiggerBanner>();
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
NPC.Calamity().VulnerableToElectricity = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
|
||||
|
||||
@@ -40,6 +40,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToCold = false;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
NPC.height = 30;
|
||||
NPC.defense = 25;
|
||||
NPC.lifeMax = 1000;
|
||||
NPC.knockBackResist = 0f;
|
||||
NPC.knockBackResist = 0.3f;
|
||||
AnimationType = NPCID.CorruptSlime;
|
||||
NPC.value = Item.buyPrice(0, 0, 25, 0);
|
||||
NPC.alpha = 50;
|
||||
@@ -37,6 +37,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
BannerItem = ModContent.ItemType<BloomSlimeBanner>();
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -32,6 +32,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
BannerItem = ModContent.ItemType<BohldohrBanner>();
|
||||
NPC.Calamity().VulnerableToSickness = false;
|
||||
NPC.Calamity().VulnerableToWater = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -47,6 +47,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
NPC.Calamity().VulnerableToWater = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -37,6 +37,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
NPC.Calamity().VulnerableToWater = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -37,6 +37,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -38,6 +38,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -37,6 +37,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
@@ -37,6 +37,10 @@ namespace CalamityMod.NPCs.NormalNPCs
|
||||
NPC.Calamity().VulnerableToHeat = true;
|
||||
NPC.Calamity().VulnerableToCold = true;
|
||||
NPC.Calamity().VulnerableToSickness = true;
|
||||
|
||||
// Scale stats in Expert and Master
|
||||
CalamityGlobalNPC.AdjustExpertModeStatScaling(NPC);
|
||||
CalamityGlobalNPC.AdjustMasterModeStatScaling(NPC);
|
||||
}
|
||||
|
||||
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
|
||||
|
||||
Loaded 100 of 259 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user