diff --git a/Craftimizer/LuminaSheets.cs b/Craftimizer/LuminaSheets.cs index e67b141..4485d83 100644 --- a/Craftimizer/LuminaSheets.cs +++ b/Craftimizer/LuminaSheets.cs @@ -2,10 +2,10 @@ using Dalamud; using Lumina; using Lumina.Data; using Lumina.Excel; -using Lumina.Excel.GeneratedSheets; -using System; +using Lumina.Excel.GeneratedSheets2; using System.Collections.Concurrent; -using Action = Lumina.Excel.GeneratedSheets.Action; +using Action = Lumina.Excel.GeneratedSheets2.Action; +using ItemFood = Lumina.Excel.GeneratedSheets.ItemFood; // BaseParam is too annoying with SoA namespace Craftimizer.Plugin; diff --git a/Craftimizer/SimulatorUtils.cs b/Craftimizer/SimulatorUtils.cs index b673ae0..2639641 100644 --- a/Craftimizer/SimulatorUtils.cs +++ b/Craftimizer/SimulatorUtils.cs @@ -6,17 +6,17 @@ using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.Object; using FFXIVClientStructs.FFXIV.Client.Game.UI; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.GeneratedSheets2; using System; using System.Globalization; using System.Linq; using System.Numerics; using System.Text; -using Action = Lumina.Excel.GeneratedSheets.Action; +using Action = Lumina.Excel.GeneratedSheets2.Action; using ActionType = Craftimizer.Simulator.Actions.ActionType; using ClassJob = Craftimizer.Simulator.ClassJob; using Condition = Craftimizer.Simulator.Condition; -using Status = Lumina.Excel.GeneratedSheets.Status; +using Status = Lumina.Excel.GeneratedSheets2.Status; namespace Craftimizer.Plugin; @@ -156,7 +156,7 @@ internal static class ClassJobUtils PlayerState.Instance()->ClassJobLevelArray[me.GetExpArrayIdx()]; public static unsafe bool CanPlayerUseManipulation(this ClassJob me) => - UIState.Instance()->IsUnlockLinkUnlockedOrQuestCompleted(ActionType.Manipulation.GetActionRow(me).Action!.UnlockLink); + UIState.Instance()->IsUnlockLinkUnlockedOrQuestCompleted(ActionType.Manipulation.GetActionRow(me).Action!.UnlockLink.Row); public static string GetName(this ClassJob me) { diff --git a/Craftimizer/Utils/FoodStatus.cs b/Craftimizer/Utils/FoodStatus.cs index 6d76985..8cf262c 100644 --- a/Craftimizer/Utils/FoodStatus.cs +++ b/Craftimizer/Utils/FoodStatus.cs @@ -1,6 +1,6 @@ using Craftimizer.Plugin; using Craftimizer.Plugin.Utils; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.GeneratedSheets2; using System.Collections.Frozen; using System.Collections.Generic; using System.Collections.Immutable; @@ -68,7 +68,7 @@ public static class FoodStatus if (stat.BaseParam == 0) continue; var foodStat = new FoodStat(stat.IsRelative, stat.Value, stat.Max, stat.ValueHQ, stat.MaxHQ); - switch (stat.BaseParam) + switch ((uint)stat.BaseParam) { case Gearsets.ParamCraftsmanship: craftsmanship = foodStat; break; case Gearsets.ParamControl: control = foodStat; break; diff --git a/Craftimizer/Utils/Gearsets.cs b/Craftimizer/Utils/Gearsets.cs index b3bc64e..321753e 100644 --- a/Craftimizer/Utils/Gearsets.cs +++ b/Craftimizer/Utils/Gearsets.cs @@ -3,7 +3,7 @@ using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.UI; using FFXIVClientStructs.FFXIV.Client.UI.Misc; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.GeneratedSheets2; using System; using System.Linq; @@ -16,9 +16,9 @@ public static unsafe class Gearsets private static readonly GearsetStats BaseStats = new(180, 0, 0); - public const int ParamCP = 11; - public const int ParamCraftsmanship = 70; - public const int ParamControl = 71; + public const uint ParamCP = 11; + public const uint ParamCraftsmanship = 70; + public const uint ParamControl = 71; private static readonly int[] LevelToCLvlLUT; @@ -67,7 +67,7 @@ public static unsafe class Gearsets int cp = 0, craftsmanship = 0, control = 0; - void IncreaseStat(int baseParam, int amount) + void IncreaseStat(uint baseParam, int amount) { if (baseParam == ParamCP) cp += amount; @@ -77,11 +77,11 @@ public static unsafe class Gearsets control += amount; } - foreach (var statIncrease in item.UnkData59) - IncreaseStat(statIncrease.BaseParam, statIncrease.BaseParamValue); + foreach (var statIncrease in item.BaseParam.Zip(item.BaseParamValue)) + IncreaseStat(statIncrease.First.Row, statIncrease.Second); if (gearsetItem.isHq) - foreach (var statIncrease in item.UnkData73) - IncreaseStat(statIncrease.BaseParamSpecial, statIncrease.BaseParamValueSpecial); + foreach (var statIncrease in item.BaseParamSpecial.Zip(item.BaseParamValueSpecial)) + IncreaseStat(statIncrease.First.Row, statIncrease.Second); foreach (var gearsetMateria in gearsetItem.materia) { @@ -89,7 +89,7 @@ public static unsafe class Gearsets continue; var materia = LuminaSheets.MateriaSheet.GetRow(gearsetMateria.Type)!; - IncreaseStat((int)materia.BaseParam.Row, materia.Value[gearsetMateria.Grade]); + IncreaseStat(materia.BaseParam.Row, materia.Value[gearsetMateria.Grade]); } cp = Math.Min(cp, CalculateParamCap(item, ParamCP)); @@ -152,10 +152,10 @@ public static unsafe class Gearsets throw new ArgumentOutOfRangeException(nameof(level), level, "Level is out of range."); // https://github.com/ffxiv-teamcraft/ffxiv-teamcraft/blob/24d0db2d9676f264edf53651b21005305267c84c/apps/client/src/app/modules/gearsets/materia.service.ts#L265 - private static int CalculateParamCap(Item item, int paramId) + private static int CalculateParamCap(Item item, uint paramId) { var ilvl = item.LevelItem.Value!; - var param = LuminaSheets.BaseParamSheet.GetRow((uint)paramId)!; + var param = LuminaSheets.BaseParamSheet.GetRow(paramId)!; var baseValue = paramId switch { @@ -167,26 +167,27 @@ public static unsafe class Gearsets // https://github.com/ffxiv-teamcraft/ffxiv-teamcraft/blob/24d0db2d9676f264edf53651b21005305267c84c/apps/data-extraction/src/extractors/items.extractor.ts#L6 var slotMod = item.EquipSlotCategory.Row switch { - 1 => param.oneHWpnPct, - 2 => param.OHPct, - 3 => param.HeadPct, - 4 => param.ChestPct, - 5 => param.HandsPct, - 6 => param.WaistPct, - 7 => param.LegsPct, - 8 => param.FeetPct, - 9 => param.EarringPct, - 10 => param.NecklacePct, - 11 => param.BraceletPct, - 12 => param.RingPct, - 13 => param.twoHWpnPct, - 14 => param.oneHWpnPct, - 15 => param.ChestHeadPct, - 16 => param.ChestHeadLegsFeetPct, - 18 => param.LegsFeetPct, - 19 => param.HeadChestHandsLegsFeetPct, - 20 => param.ChestLegsGlovesPct, - 21 => param.ChestLegsFeetPct, + 1 => param.OneHandWeaponPercent, // column 4 + 2 => param.OffHandPercent, // column 5 + 3 => param.HeadPercent, // ... + 4 => param.ChestPercent, + 5 => param.HandsPercent, + 6 => param.WaistPercent, + 7 => param.LegsPercent, + 8 => param.FeetPercent, + 9 => param.EarringPercent, + 10 => param.NecklacePercent, + 11 => param.BraceletPercent, + 12 => param.RingPercent, + 13 => param.TwoHandWeaponPercent, + 14 => param.OneHandWeaponPercent, + 15 => param.ChestHeadPercent, + 16 => param.ChestHeadLegsFeetPercent, + 17 => 0, + 18 => param.LegsFeetPercent, + 19 => param.HeadChestHandsLegsFeetPercent, + 20 => param.ChestLegsGlovesPercent, + 21 => param.ChestLegsFeetPercent, _ => 0 }; var roleMod = param.MeldParam[item.BaseParamModifier]; diff --git a/Craftimizer/Utils/RecipeData.cs b/Craftimizer/Utils/RecipeData.cs index 7caba52..03373be 100644 --- a/Craftimizer/Utils/RecipeData.cs +++ b/Craftimizer/Utils/RecipeData.cs @@ -1,6 +1,6 @@ using Craftimizer.Plugin; using Craftimizer.Simulator; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.GeneratedSheets2; using System; using System.Collections.Generic; using System.Linq; @@ -47,30 +47,34 @@ public sealed record RecipeData }; CollectableThresholds = null; - switch (Recipe.Unknown45) + switch (Recipe.Unknown1) { case 1: - var data1 = LuminaSheets.CollectablesShopRefineSheet.GetRow(Recipe.Unknown46); + var data1 = LuminaSheets.CollectablesShopRefineSheet.GetRow(Recipe.Unknown0); if (data1 == null) break; CollectableThresholds = new int?[] { data1.LowCollectability, data1.MidCollectability, data1.HighCollectability }; break; case 2: - var data2 = LuminaSheets.HWDCrafterSupplySheet.GetRow(Recipe.Unknown46); + var data2 = LuminaSheets.HWDCrafterSupplySheet.GetRow(Recipe.Unknown0); if (data2 == null) break; - var idx = Array.FindIndex(data2.ItemTradeIn, i => i.Row == Recipe.ItemResult.Row); - if (idx == -1) - break; - CollectableThresholds = new int?[] { data2.BaseCollectableRating[idx], data2.MidCollectableRating[idx], data2.HighCollectableRating[idx] }; + foreach (var entry in data2.HWDCrafterSupplyParams) + { + if (entry.ItemTradeIn.Row == Recipe.ItemResult.Row) + { + CollectableThresholds = new int?[] { entry.BaseCollectableRating, entry.MidCollectableRating, entry.HighCollectableRating }; + break; + } + } break; case 3: - var subRowCount = LuminaSheets.SatisfactionSupplySheet.GetSubRowCount(Recipe.Unknown46); + var subRowCount = LuminaSheets.SatisfactionSupplySheet.GetSubRowCount(Recipe.Unknown0); if (subRowCount is not { } subRowValue) break; for (uint i = 0; i < subRowValue; ++i) { - var data3 = LuminaSheets.SatisfactionSupplySheet.GetRow(Recipe.Unknown46, i); + var data3 = LuminaSheets.SatisfactionSupplySheet.GetRow(Recipe.Unknown0, i); if (data3 == null) continue; if (data3.Item.Row == Recipe.ItemResult.Row) @@ -81,7 +85,7 @@ public sealed record RecipeData } break; case 4: - var data4 = LuminaSheets.SharlayanCraftWorksSupplySheet.GetRow(Recipe.Unknown46); + var data4 = LuminaSheets.SharlayanCraftWorksSupplySheet.GetRow(Recipe.Unknown0); if (data4 == null) break; foreach (var item in data4.Items) @@ -97,10 +101,11 @@ public sealed record RecipeData break; } - Ingredients = Recipe.UnkData5.Take(6) - .Where(i => i != null && i.ItemIngredient != 0) - .Select(i => (LuminaSheets.ItemSheet.GetRow((uint)i.ItemIngredient)!, (int)i.AmountIngredient)) - .Where(i => i.Item1 != null).ToList(); + Ingredients = Recipe.Ingredient.Zip(Recipe.AmountIngredient) + .Take(6) + .Where(i => i.First.Value != null) + .Select(i => (i.First.Value!, (int)i.Second)) + .ToList(); MaxStartingQuality = (int)Math.Floor(Recipe.MaterialQualityFactor * RecipeInfo.MaxQuality / 100f); TotalHqILvls = (int)Ingredients.Where(i => i.Item.CanBeHq).Sum(i => i.Item.LevelItem.Row * i.Amount); diff --git a/Craftimizer/Windows/RecipeNote.cs b/Craftimizer/Windows/RecipeNote.cs index 2bd4cf3..05d2089 100644 --- a/Craftimizer/Windows/RecipeNote.cs +++ b/Craftimizer/Windows/RecipeNote.cs @@ -1043,9 +1043,15 @@ public sealed unsafe class RecipeNote : Window, IDisposable var level = LuminaSheets.LevelSheet.GetRow(levelRowId) ?? throw new ArgumentNullException(nameof(levelRowId), $"Invalid level row {levelRowId}"); var territory = level.Territory.Value!.PlaceName.Value!.Name.ToDalamudString().ToString(); - var location = MapUtil.WorldToMap(new(level.X, level.Z), level.Map.Value!); + var location = WorldToMap2(new(level.X, level.Z), level.Map.Value!); - return (ResolveNpcResidentName(level.Object), territory, location, new(level.Territory.Row, level.Map.Row, location.X, location.Y)); + return (ResolveNpcResidentName(level.Object.Row), territory, location, new(level.Territory.Row, level.Map.Row, location.X, location.Y)); + } + + // MapUtil.WorldToMap but for GeneratedSheets2 + private static Vector2 WorldToMap2(Vector2 worldCoordinates, Lumina.Excel.GeneratedSheets2.Map map) + { + return MapUtil.WorldToMap(worldCoordinates, map.OffsetX, map.OffsetY, map.SizeFactor); } private static string ResolveNpcResidentName(uint npcRowId)