Add action ids and action data lookup
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
using ImGuiScene;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Craftimizer.Plugin;
|
||||
|
||||
internal static class Icons
|
||||
{
|
||||
private static readonly Dictionary<string, TextureWrap> Cache = new();
|
||||
|
||||
public static TextureWrap GetIconFromPath(string path)
|
||||
{
|
||||
if (!Cache.TryGetValue(path, out var ret))
|
||||
Cache.Add(path, ret = Service.DataManager.GetImGuiTexture(path)!);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static TextureWrap GetIconFromId(ushort id) =>
|
||||
GetIconFromPath($"ui/icon/{id / 1000 * 1000:000000}/{id:000000}_hr1.tex");
|
||||
}
|
||||
@@ -8,4 +8,6 @@ public static class LuminaSheets
|
||||
public static readonly ExcelSheet<Recipe> RecipeSheet = Service.DataManager.GetExcelSheet<Recipe>()!;
|
||||
public static readonly ExcelSheet<RecipeLevelTable> RecipeLevelTableSheet = Service.DataManager.GetExcelSheet<RecipeLevelTable>()!;
|
||||
public static readonly ExcelSheet<ParamGrow> ParamGrowSheet = Service.DataManager.GetExcelSheet<ParamGrow>()!;
|
||||
public static readonly ExcelSheet<Action> ActionSheet = Service.DataManager.GetExcelSheet<Action>()!;
|
||||
public static readonly ExcelSheet<CraftAction> CraftActionSheet = Service.DataManager.GetExcelSheet<CraftAction>()!;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class AdvancedTouch : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Quality;
|
||||
public override int Level => 84;
|
||||
public override int ActionId => 100411;
|
||||
|
||||
public override int CPCost => Simulation.GetPreviousAction() is StandardTouch && Simulation.GetPreviousAction(2) is BasicTouch ? 18 : 46;
|
||||
public override float Efficiency => 1.50f;
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
using Craftimizer.Plugin;
|
||||
using ImGuiScene;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Action = Lumina.Excel.GeneratedSheets.Action;
|
||||
|
||||
namespace Craftimizer.Simulator.Actions;
|
||||
|
||||
internal abstract class BaseAction
|
||||
public abstract class BaseAction
|
||||
{
|
||||
public static readonly Type[] Actions = typeof(BaseAction).Assembly.GetTypes()
|
||||
.Where(type => type.IsAssignableTo(typeof(BaseAction)) && !type.IsAbstract).ToArray();
|
||||
|
||||
protected Simulation Simulation { get; }
|
||||
|
||||
public BaseAction(Simulation simulation)
|
||||
@@ -11,12 +21,65 @@ internal abstract class BaseAction
|
||||
|
||||
public abstract ActionCategory Category { get; }
|
||||
public abstract int Level { get; }
|
||||
// Doesn't matter from which class, we'll use the sheet to extrapolate the rest
|
||||
public abstract int ActionId { get; }
|
||||
|
||||
public abstract int CPCost { get; }
|
||||
public abstract float Efficiency { get; }
|
||||
public virtual float SuccessRate => 1f;
|
||||
public virtual int DurabilityCost => 10;
|
||||
|
||||
private (CraftAction? CraftAction, Action? Action) GetActionRow(ClassJob classJob)
|
||||
{
|
||||
if (LuminaSheets.CraftActionSheet.GetRow((uint)ActionId) is CraftAction baseCraftAction)
|
||||
{
|
||||
return (classJob switch
|
||||
{
|
||||
ClassJob.Carpenter => baseCraftAction.CRP.Value!,
|
||||
ClassJob.Blacksmith => baseCraftAction.BSM.Value!,
|
||||
ClassJob.Armorer => baseCraftAction.ARM.Value!,
|
||||
ClassJob.Goldsmith => baseCraftAction.GSM.Value!,
|
||||
ClassJob.Leatherworker => baseCraftAction.LTW.Value!,
|
||||
ClassJob.Weaver => baseCraftAction.WVR.Value!,
|
||||
ClassJob.Alchemist => baseCraftAction.ALC.Value!,
|
||||
ClassJob.Culinarian => baseCraftAction.CUL.Value!,
|
||||
_ => baseCraftAction
|
||||
}, null);
|
||||
}
|
||||
else if (LuminaSheets.ActionSheet.GetRow((uint)ActionId) is Action baseAction)
|
||||
{
|
||||
return (null,
|
||||
LuminaSheets.ActionSheet.First(r =>
|
||||
r.Icon == baseAction.Icon &&
|
||||
r.ActionCategory.Row == baseAction.ActionCategory.Row &&
|
||||
r.Name.RawString == baseAction.Name.RawString &&
|
||||
(r.ClassJobCategory.Value?.IsClassJob(classJob) ?? false)
|
||||
));
|
||||
}
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
public string GetName(ClassJob classJob)
|
||||
{
|
||||
var (craftAction, action) = GetActionRow(classJob);
|
||||
if (craftAction != null)
|
||||
return craftAction.Name;
|
||||
else if (action != null)
|
||||
return action.Name;
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
public TextureWrap GetIcon(ClassJob classJob)
|
||||
{
|
||||
var (craftAction, action) = GetActionRow(classJob);
|
||||
if (craftAction != null)
|
||||
return Icons.GetIconFromId(craftAction.Icon);
|
||||
else if (action != null)
|
||||
return Icons.GetIconFromId(action.Icon);
|
||||
// Old "Steady Hand" action icon
|
||||
return Icons.GetIconFromId(1953);
|
||||
}
|
||||
|
||||
public virtual bool CanUse =>
|
||||
Simulation.Stats.Level >= Level && Simulation.CP >= CPCost;
|
||||
|
||||
@@ -24,10 +87,13 @@ internal abstract class BaseAction
|
||||
{
|
||||
Simulation.ReduceCP(CPCost);
|
||||
Simulation.ReduceDurability(DurabilityCost);
|
||||
|
||||
if (Simulation.RollSuccess(SuccessRate))
|
||||
UseSuccess();
|
||||
|
||||
if (Simulation.HasEffect(Effect.Manipulation))
|
||||
Simulation.RestoreDurability(5);
|
||||
}
|
||||
|
||||
public abstract void UseSuccess();
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class BasicSynthesis : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Synthesis;
|
||||
public override int Level => 1;
|
||||
public override int ActionId => 100001;
|
||||
|
||||
public override int CPCost => 0;
|
||||
// Basic Synthesis Mastery Trait
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class BasicTouch : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Quality;
|
||||
public override int Level => 5;
|
||||
public override int ActionId => 100002;
|
||||
|
||||
public override int CPCost => 18;
|
||||
public override float Efficiency => 1.00f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class ByregotsBlessing : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Quality;
|
||||
public override int Level => 50;
|
||||
public override int ActionId => 100339;
|
||||
|
||||
public override int CPCost => 24;
|
||||
public override float Efficiency => 1.00f + 0.20f * (Simulation.GetEffect(Effect.InnerQuiet)?.Strength ?? 0);
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class CarefulSynthesis : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Synthesis;
|
||||
public override int Level => 62;
|
||||
public override int ActionId => 100203;
|
||||
|
||||
public override int CPCost => 7;
|
||||
// Careful Synthesis Mastery Trait
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class DelicateSynthesis : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Synthesis;
|
||||
public override int Level => 76;
|
||||
public override int ActionId => 100323;
|
||||
|
||||
public override int CPCost => 32;
|
||||
public override float Efficiency => 1.00f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class FinalAppraisal : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Synthesis;
|
||||
public override int Level => 42;
|
||||
public override int ActionId => 19012;
|
||||
|
||||
public override int CPCost => 1;
|
||||
public override float Efficiency => 0f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class FocusedSynthesis : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Synthesis;
|
||||
public override int Level => 67;
|
||||
public override int ActionId => 100235;
|
||||
|
||||
public override int CPCost => 5;
|
||||
public override float Efficiency => 2.00f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class FocusedTouch : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Quality;
|
||||
public override int Level => 68;
|
||||
public override int ActionId => 100243;
|
||||
|
||||
public override int CPCost => 18;
|
||||
public override float Efficiency => 1.50f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class GreatStrides : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Buffs;
|
||||
public override int Level => 21;
|
||||
public override int ActionId => 260;
|
||||
|
||||
public override int CPCost => 32;
|
||||
public override float Efficiency => 0f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class Groundwork : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Synthesis;
|
||||
public override int Level => 72;
|
||||
public override int ActionId => 100403;
|
||||
|
||||
public override int CPCost => 18;
|
||||
// Groundwork Mastery Trait
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class HastyTouch : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Quality;
|
||||
public override int Level => 9;
|
||||
public override int ActionId => 100355;
|
||||
|
||||
public override int CPCost => 0;
|
||||
public override float Efficiency => 1.00f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class Innovation : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Buffs;
|
||||
public override int Level => 26;
|
||||
public override int ActionId => 19004;
|
||||
|
||||
public override int CPCost => 18;
|
||||
public override float Efficiency => 0f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class IntensiveSynthesis : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Synthesis;
|
||||
public override int Level => 78;
|
||||
public override int ActionId => 100315;
|
||||
|
||||
public override int CPCost => 6;
|
||||
public override float Efficiency => 4.00f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class Manipulation : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Durability;
|
||||
public override int Level => 65;
|
||||
public override int ActionId => 4574;
|
||||
|
||||
public override int CPCost => 96;
|
||||
public override float Efficiency => 0f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class MastersMend : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Durability;
|
||||
public override int Level => 7;
|
||||
public override int ActionId => 100003;
|
||||
|
||||
public override int CPCost => 88;
|
||||
public override float Efficiency => 0f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class MuscleMemory : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.FirstTurn;
|
||||
public override int Level => 54;
|
||||
public override int ActionId => 100379;
|
||||
|
||||
public override int CPCost => 6;
|
||||
public override float Efficiency => 3.00f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class Observe : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Other;
|
||||
public override int Level => 13;
|
||||
public override int ActionId => 100010;
|
||||
|
||||
public override int CPCost => 7;
|
||||
public override float Efficiency => 0f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class PreciseTouch : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Quality;
|
||||
public override int Level => 53;
|
||||
public override int ActionId => 100128;
|
||||
|
||||
public override int CPCost => 18;
|
||||
public override float Efficiency => 1.50f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class PreparatoryTouch : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Quality;
|
||||
public override int Level => 71;
|
||||
public override int ActionId => 100299;
|
||||
|
||||
public override int CPCost => 40;
|
||||
public override float Efficiency => 2.00f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class PrudentSynthesis : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Synthesis;
|
||||
public override int Level => 88;
|
||||
public override int ActionId => 100427;
|
||||
|
||||
public override int CPCost => 18;
|
||||
public override float Efficiency => 1.80f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class PrudentTouch : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Quality;
|
||||
public override int Level => 66;
|
||||
public override int ActionId => 100227;
|
||||
|
||||
public override int CPCost => 25;
|
||||
public override float Efficiency => 1.00f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class RapidSynthesis : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Synthesis;
|
||||
public override int Level => 9;
|
||||
public override int ActionId => 100363;
|
||||
|
||||
public override int CPCost => 0;
|
||||
// Rapid Synthesis Mastery Trait
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class Reflect : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.FirstTurn;
|
||||
public override int Level => 69;
|
||||
public override int ActionId => 100387;
|
||||
|
||||
public override int CPCost => 6;
|
||||
public override float Efficiency => 1.00f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class StandardTouch : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Quality;
|
||||
public override int Level => 18;
|
||||
public override int ActionId => 100004;
|
||||
|
||||
public override int CPCost => Simulation.GetPreviousAction() is BasicTouch ? 18 : 32;
|
||||
public override float Efficiency => 1.25f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class TrainedEye : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.FirstTurn;
|
||||
public override int Level => 80;
|
||||
public override int ActionId => 100283;
|
||||
|
||||
public override int CPCost => 250;
|
||||
public override float Efficiency => 0f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class TrainedFinesse : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Quality;
|
||||
public override int Level => 90;
|
||||
public override int ActionId => 100435;
|
||||
|
||||
public override int CPCost => 32;
|
||||
public override float Efficiency => 1.00f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class TricksOfTheTrade : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Other;
|
||||
public override int Level => 13;
|
||||
public override int ActionId => 100371;
|
||||
|
||||
public override int CPCost => 0;
|
||||
public override float Efficiency => 0f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class Veneration : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Buffs;
|
||||
public override int Level => 15;
|
||||
public override int ActionId => 19297;
|
||||
|
||||
public override int CPCost => 18;
|
||||
public override float Efficiency => 0f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class WasteNot : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Durability;
|
||||
public override int Level => 15;
|
||||
public override int ActionId => 4631;
|
||||
|
||||
public override int CPCost => 56;
|
||||
public override float Efficiency => 0f;
|
||||
|
||||
@@ -6,6 +6,7 @@ internal class WasteNot2 : BaseAction
|
||||
|
||||
public override ActionCategory Category => ActionCategory.Durability;
|
||||
public override int Level => 47;
|
||||
public override int ActionId => 4639;
|
||||
|
||||
public override int CPCost => 98;
|
||||
public override float Efficiency => 0f;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace Craftimizer.Simulator;
|
||||
|
||||
public enum ClassJob
|
||||
{
|
||||
Carpenter,
|
||||
Blacksmith,
|
||||
Armorer,
|
||||
Goldsmith,
|
||||
Leatherworker,
|
||||
Weaver,
|
||||
Alchemist,
|
||||
Culinarian
|
||||
}
|
||||
|
||||
internal static class ClassJobExtensions
|
||||
{
|
||||
public static bool IsClassJob(this ClassJobCategory me, ClassJob classJob)
|
||||
{
|
||||
return classJob switch
|
||||
{
|
||||
ClassJob.Carpenter => me.CRP,
|
||||
ClassJob.Blacksmith => me.BSM,
|
||||
ClassJob.Armorer => me.ARM,
|
||||
ClassJob.Goldsmith => me.GSM,
|
||||
ClassJob.Leatherworker => me.LTW,
|
||||
ClassJob.Weaver => me.WVR,
|
||||
ClassJob.Alchemist => me.ALC,
|
||||
ClassJob.Culinarian => me.CUL,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user