Add skill level, attribute, vitals, and appraisal engine API

- InqSkill with raw param (0=buffed, 1=base incl. attribute contribution)
- InqAttribute for primary attributes (Str/End/Qui/Coo/Foc/Self, buffed + base)
- InqAttribute2nd for max vitals base level (health/stamina/mana)
- InqInt64 delegate for quad properties
- AppraisalHooks: full item appraisal support via AC client appraisal path
- PlayerVitalsHooks and BusyCountHooks additions
- Expose all new hooks through PluginContract/PluginManager/RynthCoreApiNative/RynthCoreHost (contract version 46)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
tombohar 2026-04-12 21:06:22 -04:00
commit 610c9feaec
9 changed files with 764 additions and 7 deletions

View file

@ -170,7 +170,8 @@ internal struct RynthCoreAPI
/// <summary>Function pointer: int ObjectIsAttackable(uint objectId) — calls ClientCombatSystem::ObjectIsAttackable, returns 1 if attackable</summary>
public IntPtr ObjectIsAttackableFn;
/// <summary>Function pointer: int GetObjectSkill(uint objectId, uint skillStype, int* buffed, int* training)</summary>
/// <summary>Function pointer: int GetObjectSkill(uint objectId, uint skillStype, int* base, int* training)
/// base = InitialLevel + LevelFromPracticePoints (no enchantments). training: 0=Unusable,1=Untrained,2=Trained,3=Specialized.</summary>
public IntPtr GetObjectSkillFn;
/// <summary>Function pointer: int IsSpellKnown(uint objectId, uint spellId) — returns 1 if in spell book</summary>
@ -244,6 +245,29 @@ internal struct RynthCoreAPI
/// </summary>
public IntPtr GetObjectDoublePropertyFn;
/// <summary>
/// Function pointer: int GetObjectQuadProperty(uint objectId, uint stype, __int64* value)
/// Reads an STypeInt64 (quad) property from any game object.
/// Returns 1 on success, 0 if undefined.
/// </summary>
public IntPtr GetObjectQuadPropertyFn;
/// <summary>
/// Function pointer: int GetObjectAttribute2ndBaseLevel(uint objectId, uint stype2nd, ulong* value)
/// Reads the unbuffed base maximum vital via CACQualities::InqAttribute2ndBaseLevel.
/// stype2nd: 1=MAX_HEALTH, 3=MAX_STAMINA, 5=MAX_MANA.
/// Returns 1 on success, 0 if unavailable.
/// </summary>
public IntPtr GetObjectAttribute2ndBaseLevelFn;
/// <summary>
/// Function pointer: int GetPlayerBaseVitals(uint* baseMaxHp, uint* baseMaxStam, uint* baseMaxMana)
/// Returns unbuffed base maximum vitals via InqAttribute2ndStruct(_initLevel + _levelFromCp).
/// Excludes spell enchantments; includes base training, gear, and augmentations.
/// Returns 1 on success, 0 if player qualities not yet available.
/// </summary>
public IntPtr GetPlayerBaseVitalsFn;
/// <summary>
/// Function pointer: IntPtr GetObjectStringProperty(uint objectId, uint stype)
/// Returns pointer to ANSI string data, or IntPtr.Zero if undefined.
@ -363,12 +387,55 @@ internal struct RynthCoreAPI
/// Returns 0 if the object is not found or the phys_obj offset is not yet probed.
/// </summary>
public IntPtr GetObjectWcidFn;
/// <summary>
/// Function pointer: int HasAppraisalData(uint objectId)
/// Returns 1 if a SendNotice_SetAppraiseInfo has been received for this guid this session, 0 otherwise.
/// </summary>
public IntPtr HasAppraisalDataFn;
/// <summary>
/// Function pointer: long GetLastIdTime(uint objectId)
/// Returns the Unix timestamp (seconds) of the last appraisal receipt for this guid, or 0 if never.
/// </summary>
public IntPtr GetLastIdTimeFn;
/// <summary>
/// Function pointer: int GetObjectHeading(uint objectId, float* headingDegrees)
/// Returns the object's facing direction (0–360°, clockwise, 0=North). Returns 1 on success, 0 on failure.
/// </summary>
public IntPtr GetObjectHeadingFn;
/// <summary>
/// Function pointer: int GetBusyState()
/// Returns 0 if the character is idle, positive if a UI action is in progress.
/// </summary>
public IntPtr GetBusyStateFn;
/// <summary>
/// Function pointer: int GetObjectSpellIds(uint objectId, uint* spellIds, int maxCount)
/// Fills spellIds with the spell book IDs from the last server appraisal for this object.
/// Returns total count (may exceed maxCount), or -1 if no appraisal data is cached.
/// Requires the player to have identified (RequestId) the object this session.
/// </summary>
public IntPtr GetObjectSpellIdsFn;
/// <summary>Function pointer: int GetObjectSkillBuffed(uint objectId, uint skillStype, int* buffed)
/// Returns the live buffed skill level (with spell enchantments) via InqSkill(raw=0).</summary>
public IntPtr GetObjectSkillBuffedFn;
/// <summary>Function pointer: int GetObjectAttribute(uint objectId, uint stype, int raw, uint* value)
/// Reads a primary attribute via InqAttribute. raw=0→buffed, raw=1→base.
/// stype: 1=Strength, 2=Endurance, 3=Quickness, 4=Coordination, 5=Focus, 6=Self.</summary>
public IntPtr GetObjectAttributeFn;
}
/// <summary>Current API version. Bump when adding fields to RynthCoreAPI.</summary>
internal static class PluginContractVersion
{
public const uint Current = 40;
public const uint Current = 46;
}
internal static class ClientActionHookFlags
@ -671,6 +738,15 @@ internal delegate int InvokeChatParserCallbackDelegate(IntPtr textUtf16);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal unsafe delegate int GetObjectDoublePropertyCallbackDelegate(uint objectId, uint stype, double* value);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal unsafe delegate int GetObjectQuadPropertyCallbackDelegate(uint objectId, uint stype, long* value);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal unsafe delegate int GetObjectAttribute2ndBaseLevelCallbackDelegate(uint objectId, uint stype2nd, uint* value);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal unsafe delegate int GetPlayerBaseVitalsCallbackDelegate(uint* baseMaxHp, uint* baseMaxStam, uint* baseMaxMana);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate IntPtr GetObjectStringPropertyCallbackDelegate(uint objectId, uint stype);
@ -704,3 +780,24 @@ internal delegate IntPtr GetWorldNameCallbackDelegate();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate uint GetObjectWcidCallbackDelegate(uint objectId);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int HasAppraisalDataCallbackDelegate(uint objectId);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate long GetLastIdTimeCallbackDelegate(uint objectId);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal unsafe delegate int GetObjectHeadingCallbackDelegate(uint objectId, float* headingDegrees);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int GetBusyStateCallbackDelegate();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal unsafe delegate int GetObjectSpellIdsCallbackDelegate(uint guid, uint* spellIds, int maxCount);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal unsafe delegate int GetObjectSkillLevelCallbackDelegate(uint objectId, uint skillStype, int raw, int* level);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal unsafe delegate int GetObjectAttributeCallbackDelegate(uint objectId, uint stype, int raw, uint* value);

View file

@ -149,6 +149,9 @@ internal static class PluginManager
private static Nav3DAddLineCallbackDelegate? _nav3DAddLineCallback;
private static InvokeChatParserCallbackDelegate? _invokeChatParserCallback;
private static GetObjectDoublePropertyCallbackDelegate? _getObjectDoublePropertyCallback;
private static GetObjectQuadPropertyCallbackDelegate? _getObjectQuadPropertyCallback;
private static GetObjectAttribute2ndBaseLevelCallbackDelegate? _getObjectAttribute2ndBaseLevelCallback;
private static GetPlayerBaseVitalsCallbackDelegate? _getPlayerBaseVitalsCallback;
private static GetObjectStringPropertyCallbackDelegate? _getObjectStringPropertyCallback;
private static GetObjectWielderInfoCallbackDelegate? _getObjectWielderInfoCallback;
private static NativeAttackCallbackDelegate? _nativeAttackCallback;
@ -164,6 +167,13 @@ internal static class PluginManager
private static GetAccountNameCallbackDelegate? _getAccountNameCallback;
private static GetWorldNameCallbackDelegate? _getWorldNameCallback;
private static GetObjectWcidCallbackDelegate? _getObjectWcidCallback;
private static HasAppraisalDataCallbackDelegate? _hasAppraisalDataCallback;
private static GetLastIdTimeCallbackDelegate? _getLastIdTimeCallback;
private static GetObjectHeadingCallbackDelegate? _getObjectHeadingCallback;
private static GetBusyStateCallbackDelegate? _getBusyStateCallback;
private static GetObjectSpellIdsCallbackDelegate? _getObjectSpellIdsCallback;
private static GetObjectSkillLevelCallbackDelegate? _getObjectSkillBuffedCallback;
private static GetObjectAttributeCallbackDelegate? _getObjectAttributeCallback;
private static IntPtr _accountNameScratchPtr;
private static IntPtr _worldNameScratchPtr;
[ThreadStatic] private static IntPtr _objectNameScratchPtr;
@ -1569,6 +1579,9 @@ internal static class PluginManager
_nav3DAddLineCallback ??= D3D9.Nav3DRenderer.Nav3DAddLineCallback;
_invokeChatParserCallback ??= InvokeChatParser;
_getObjectDoublePropertyCallback ??= GetObjectDoublePropertyAction;
_getObjectQuadPropertyCallback ??= GetObjectQuadPropertyAction;
_getObjectAttribute2ndBaseLevelCallback ??= GetObjectAttribute2ndBaseLevelAction;
_getPlayerBaseVitalsCallback ??= GetPlayerBaseVitalsAction;
_getObjectStringPropertyCallback ??= GetObjectStringPropertyAction;
_getObjectWielderInfoCallback ??= GetObjectWielderInfoAction;
_nativeAttackCallback ??= NativeAttackAction;
@ -1584,6 +1597,13 @@ internal static class PluginManager
_getAccountNameCallback ??= GetAccountNameAction;
_getWorldNameCallback ??= GetWorldNameAction;
_getObjectWcidCallback ??= GetObjectWcidAction;
_hasAppraisalDataCallback ??= HasAppraisalDataAction;
_getLastIdTimeCallback ??= GetLastIdTimeAction;
_getObjectHeadingCallback ??= GetObjectHeadingAction;
_getBusyStateCallback ??= GetBusyStateAction;
_getObjectSpellIdsCallback ??= GetObjectSpellIdsAction;
_getObjectSkillBuffedCallback ??= GetObjectSkillLevelAction;
_getObjectAttributeCallback ??= GetObjectAttributeAction;
_api.Version = PluginContractVersion.Current;
_api.LogFn = Marshal.GetFunctionPointerForDelegate(_logCallback);
@ -1642,6 +1662,9 @@ internal static class PluginManager
_api.Nav3DAddLineFn = Marshal.GetFunctionPointerForDelegate(_nav3DAddLineCallback);
_api.InvokeChatParserFn = Marshal.GetFunctionPointerForDelegate(_invokeChatParserCallback);
_api.GetObjectDoublePropertyFn = Marshal.GetFunctionPointerForDelegate(_getObjectDoublePropertyCallback);
_api.GetObjectQuadPropertyFn = Marshal.GetFunctionPointerForDelegate(_getObjectQuadPropertyCallback);
_api.GetObjectAttribute2ndBaseLevelFn = Marshal.GetFunctionPointerForDelegate(_getObjectAttribute2ndBaseLevelCallback);
_api.GetPlayerBaseVitalsFn = Marshal.GetFunctionPointerForDelegate(_getPlayerBaseVitalsCallback);
_api.GetObjectStringPropertyFn = Marshal.GetFunctionPointerForDelegate(_getObjectStringPropertyCallback);
_api.GetObjectWielderInfoFn = Marshal.GetFunctionPointerForDelegate(_getObjectWielderInfoCallback);
_api.NativeAttackFn = Marshal.GetFunctionPointerForDelegate(_nativeAttackCallback);
@ -1659,6 +1682,13 @@ internal static class PluginManager
_api.GetAccountNameFn = Marshal.GetFunctionPointerForDelegate(_getAccountNameCallback);
_api.GetWorldNameFn = Marshal.GetFunctionPointerForDelegate(_getWorldNameCallback);
_api.GetObjectWcidFn = Marshal.GetFunctionPointerForDelegate(_getObjectWcidCallback);
_api.HasAppraisalDataFn = Marshal.GetFunctionPointerForDelegate(_hasAppraisalDataCallback);
_api.GetLastIdTimeFn = Marshal.GetFunctionPointerForDelegate(_getLastIdTimeCallback);
_api.GetObjectHeadingFn = Marshal.GetFunctionPointerForDelegate(_getObjectHeadingCallback);
_api.GetBusyStateFn = Marshal.GetFunctionPointerForDelegate(_getBusyStateCallback);
_api.GetObjectSpellIdsFn = Marshal.GetFunctionPointerForDelegate(_getObjectSpellIdsCallback);
_api.GetObjectSkillBuffedFn = Marshal.GetFunctionPointerForDelegate(_getObjectSkillBuffedCallback);
_api.GetObjectAttributeFn = Marshal.GetFunctionPointerForDelegate(_getObjectAttributeCallback);
}
private static void ProbeClientHooks()
@ -1779,6 +1809,35 @@ internal static class PluginManager
return 1;
}
private static unsafe int GetObjectQuadPropertyAction(uint objectId, uint stype, long* value)
{
if (!ClientObjectHooks.TryGetObjectQuadProperty(objectId, stype, out long v))
return 0;
*value = v;
return 1;
}
private static unsafe int GetObjectAttribute2ndBaseLevelAction(uint objectId, uint stype2nd, uint* value)
{
if (!ClientObjectHooks.TryGetObjectAttribute2ndBaseLevel(objectId, stype2nd, out uint v))
return 0;
*value = v;
return 1;
}
private static unsafe int GetPlayerBaseVitalsAction(uint* baseMaxHp, uint* baseMaxStam, uint* baseMaxMana)
{
if (!PlayerVitalsHooks.TryGetPlayerBaseVitals(out uint hp, out uint stam, out uint mana))
return 0;
*baseMaxHp = hp;
*baseMaxStam = stam;
*baseMaxMana = mana;
return 1;
}
private static unsafe int GetObjectBoolPropertyAction(uint objectId, uint stype, int* value)
{
if (!ClientObjectHooks.TryGetObjectBoolProperty(objectId, stype, out bool v))
@ -1863,6 +1922,22 @@ internal static class PluginManager
return 1;
}
private static unsafe int GetObjectSkillLevelAction(uint objectId, uint skillStype, int raw, int* level)
{
if (!ClientObjectHooks.TryGetObjectSkillLevel(objectId, skillStype, raw, out int v))
return 0;
*level = v;
return 1;
}
private static unsafe int GetObjectAttributeAction(uint objectId, uint stype, int raw, uint* value)
{
if (!ClientObjectHooks.TryGetObjectAttribute(objectId, stype, raw, out uint v))
return 0;
*value = v;
return 1;
}
private static unsafe int ReadPlayerEnchantmentsAction(uint* spellIds, double* expiryTimes, int maxCount)
{
return EnchantmentHooks.ReadPlayerEnchantments(spellIds, expiryTimes, maxCount);
@ -2109,6 +2184,41 @@ internal static class PluginManager
return ClientObjectHooks.TryGetObjectWcid(objectId, out uint wcid) ? wcid : 0u;
}
private static int HasAppraisalDataAction(uint objectId)
{
return AppraisalHooks.HasAppraisalData(objectId) ? 1 : 0;
}
private static long GetLastIdTimeAction(uint objectId)
{
return AppraisalHooks.GetLastIdTime(objectId);
}
private static unsafe int GetObjectHeadingAction(uint objectId, float* headingDegrees)
{
if (!ClientObjectHooks.TryGetObjectHeading(objectId, out float h))
return 0;
*headingDegrees = h;
return 1;
}
private static int GetBusyStateAction() => BusyCountHooks.GetBusyState();
private static unsafe int GetObjectSpellIdsAction(uint guid, uint* spellIds, int maxCount)
{
if (spellIds == null || maxCount <= 0)
return -1;
var output = new uint[maxCount];
int result = AppraisalHooks.GetObjectSpellIds(guid, output, maxCount);
if (result > 0)
{
int count = Math.Min(result, maxCount);
for (int i = 0; i < count; i++)
spellIds[i] = output[i];
}
return result;
}
private static unsafe int GetPlayerPose(
uint* objCellId,
float* x,