Add WKS level sync support
This commit is contained in:
@@ -14,6 +14,7 @@ using Craftimizer.Utils;
|
|||||||
using Lumina.Text.ReadOnly;
|
using Lumina.Text.ReadOnly;
|
||||||
using Lumina.Text.Payloads;
|
using Lumina.Text.Payloads;
|
||||||
using Lumina.Excel.Sheets;
|
using Lumina.Excel.Sheets;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.Game.Event;
|
||||||
|
|
||||||
namespace Craftimizer.Plugin;
|
namespace Craftimizer.Plugin;
|
||||||
|
|
||||||
@@ -140,6 +141,21 @@ internal static class ClassJobUtils
|
|||||||
public static unsafe short GetPlayerLevel(this ClassJob me) =>
|
public static unsafe short GetPlayerLevel(this ClassJob me) =>
|
||||||
PlayerState.Instance()->ClassJobLevels[me.GetExpArrayIdx()];
|
PlayerState.Instance()->ClassJobLevels[me.GetExpArrayIdx()];
|
||||||
|
|
||||||
|
public static unsafe ushort GetWKSSyncedLevel(this ClassJob me)
|
||||||
|
{
|
||||||
|
var jobLevel = (ushort)me.GetPlayerLevel();
|
||||||
|
var handler = CSCraftEventHandler.Instance();
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < 2; ++i)
|
||||||
|
{
|
||||||
|
if (handler->WKSClassJobs[i] == me.GetClassJobIndex())
|
||||||
|
return Math.Min(jobLevel, handler->WKSClassLevels[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jobLevel;
|
||||||
|
}
|
||||||
|
|
||||||
public static unsafe bool CanPlayerUseManipulation(this ClassJob me) =>
|
public static unsafe bool CanPlayerUseManipulation(this ClassJob me) =>
|
||||||
UIState.Instance()->IsUnlockLinkUnlockedOrQuestCompleted(ActionType.Manipulation.GetActionRow(me).Action!.Value.UnlockLink.RowId);
|
UIState.Instance()->IsUnlockLinkUnlockedOrQuestCompleted(ActionType.Manipulation.GetActionRow(me).Action!.Value.UnlockLink.RowId);
|
||||||
|
|
||||||
|
|||||||
@@ -21,23 +21,32 @@ public sealed record RecipeData
|
|||||||
public IReadOnlyList<int?>? CollectableThresholds { get; }
|
public IReadOnlyList<int?>? CollectableThresholds { get; }
|
||||||
public IReadOnlyList<(Item Item, int Amount)> Ingredients { get; }
|
public IReadOnlyList<(Item Item, int Amount)> Ingredients { get; }
|
||||||
public int MaxStartingQuality { get; }
|
public int MaxStartingQuality { get; }
|
||||||
|
public ushort? AdjustedJobLevel { get; }
|
||||||
private int TotalHqILvls { get; }
|
private int TotalHqILvls { get; }
|
||||||
|
|
||||||
public RecipeData(ushort recipeId)
|
public RecipeData(ushort recipeId, ushort? explicitlyAdjustedJobLevel = null)
|
||||||
{
|
{
|
||||||
RecipeId = recipeId;
|
RecipeId = recipeId;
|
||||||
|
|
||||||
Recipe = LuminaSheets.RecipeSheet.GetRowOrDefault(recipeId) ??
|
Recipe = LuminaSheets.RecipeSheet.GetRowOrDefault(recipeId) ??
|
||||||
throw new ArgumentException($"Invalid recipe id {recipeId}", nameof(recipeId));
|
throw new ArgumentException($"Invalid recipe id {recipeId}", nameof(recipeId));
|
||||||
|
|
||||||
Table = Recipe.RecipeLevelTable.Value;
|
|
||||||
ClassJob = (ClassJob)Recipe.CraftType.RowId;
|
ClassJob = (ClassJob)Recipe.CraftType.RowId;
|
||||||
|
|
||||||
|
var resolvedLevelTableRow = Recipe.RecipeLevelTable.RowId;
|
||||||
|
if (Recipe.Unknown0 != 0)
|
||||||
|
{
|
||||||
|
AdjustedJobLevel = Math.Min(explicitlyAdjustedJobLevel ?? ClassJob.GetWKSSyncedLevel(), Recipe.Unknown0);
|
||||||
|
resolvedLevelTableRow = LuminaSheets.GathererCrafterLvAdjustTableSheet.GetRow(AdjustedJobLevel.Value).Unknown0;
|
||||||
|
}
|
||||||
|
Table = LuminaSheets.RecipeLevelTableSheet.GetRow(resolvedLevelTableRow);
|
||||||
|
|
||||||
RecipeInfo = new()
|
RecipeInfo = new()
|
||||||
{
|
{
|
||||||
IsExpert = Recipe.IsExpert,
|
IsExpert = Recipe.IsExpert,
|
||||||
ClassJobLevel = Table.ClassJobLevel,
|
ClassJobLevel = Table.ClassJobLevel,
|
||||||
ConditionsFlag = Table.ConditionsFlag,
|
ConditionsFlag = Table.ConditionsFlag,
|
||||||
MaxDurability = Table.Durability * Recipe.DurabilityFactor / 100,
|
MaxDurability = (Recipe.Unknown0 != 0 ? 80 : Table.Durability) * Recipe.DurabilityFactor / 100,
|
||||||
MaxQuality = (Recipe.CanHq || Recipe.IsExpert) ? (int)Table.Quality * Recipe.QualityFactor / 100 : 0,
|
MaxQuality = (Recipe.CanHq || Recipe.IsExpert) ? (int)Table.Quality * Recipe.QualityFactor / 100 : 0,
|
||||||
MaxProgress = Table.Difficulty * Recipe.DifficultyFactor / 100,
|
MaxProgress = Table.Difficulty * Recipe.DifficultyFactor / 100,
|
||||||
QualityModifier = Table.QualityModifier,
|
QualityModifier = Table.QualityModifier,
|
||||||
|
|||||||
Reference in New Issue
Block a user