mirror of
https://github.com/brues-code/nampower.git
synced 2026-10-09 07:00:00 +00:00
fix missing spell charges information in inventory functions
This commit is contained in:
+2
-2
@@ -334,7 +334,7 @@ For the player, item info includes:
|
||||
- `itemId`: The item's ID
|
||||
- `stackCount`: Number of items in the stack
|
||||
- `duration`: Item duration in milliseconds
|
||||
- `spellCharges`: Table of spell charges (indices 1-5)
|
||||
- `spellChargesRemaining`: Remaining spell charges as a single number. It uses the largest absolute value found in the internal 5-slot spell-charge array.
|
||||
- `flags`: Item flags
|
||||
- `permanentEnchantId`: Permanent enchantment ID
|
||||
- `tempEnchantId`: Temporary enchantment ID
|
||||
@@ -416,7 +416,7 @@ If no bagIndex is specified, the function returns a nested table reference conta
|
||||
- -2 = Keyring
|
||||
|
||||
Item info table fields (same as GetEquippedItems for player):
|
||||
- `itemId`, `stackCount`, `duration`, `spellCharges`, `flags`
|
||||
- `itemId`, `stackCount`, `duration`, `spellChargesRemaining`, `flags`
|
||||
- `permanentEnchantId`, `tempEnchantId`, `tempEnchantmentTimeLeftMs`, `tempEnchantmentCharges`
|
||||
- `durability`, `maxDurability`
|
||||
|
||||
|
||||
+11260
-11273
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -377,7 +377,7 @@ namespace game {
|
||||
uint64_t giftCreator;
|
||||
uint32_t stackCount;
|
||||
uint32_t duration;
|
||||
uint32_t spellCharges[5];
|
||||
int32_t spellChargesRemaining[5]; // for some reason these are stored as negative values
|
||||
uint32_t flags;
|
||||
ItemEnchantment permEnchantmentSlot;
|
||||
ItemEnchantment tempEnchantmentSlot;
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace Nampower {
|
||||
static char tempEnchantIdKey[] = "tempEnchantId";
|
||||
static char stackCountKey[] = "stackCount";
|
||||
static char durationKey[] = "duration";
|
||||
static char spellChargesRemainingKey[] = "spellChargesRemaining";
|
||||
static char flagsKey[] = "flags";
|
||||
static char durabilityKey[] = "durability";
|
||||
static char maxDurabilityKey[] = "maxDurability";
|
||||
@@ -53,6 +54,21 @@ namespace Nampower {
|
||||
static char textureKey[] = "texture";
|
||||
static char itemLevelKey[] = "itemLevel";
|
||||
|
||||
int32_t NormalizeSpellChargeValue(int32_t chargeValue) {
|
||||
return chargeValue < 0 ? -chargeValue : chargeValue;
|
||||
}
|
||||
|
||||
int32_t GetMaxSpellChargesRemaining(const int32_t *spellChargesRemaining) {
|
||||
int32_t maxChargesRemaining = 0;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
int32_t normalizedValue = NormalizeSpellChargeValue(spellChargesRemaining[i]);
|
||||
if (normalizedValue > maxChargesRemaining) {
|
||||
maxChargesRemaining = normalizedValue;
|
||||
}
|
||||
}
|
||||
return maxChargesRemaining;
|
||||
}
|
||||
|
||||
void PushItemFoundResult(uintptr_t *luaState, int32_t bagIndex, uint32_t slot) {
|
||||
uint32_t adjustedSlot = slot;
|
||||
if (bagIndex == 0) {
|
||||
@@ -96,6 +112,7 @@ namespace Nampower {
|
||||
PushTableValue(luaState, itemIdKey, itemId);
|
||||
PushTableValue(luaState, stackCountKey, itemFields->stackCount);
|
||||
PushTableValue(luaState, durationKey, itemFields->duration);
|
||||
PushTableValue(luaState, spellChargesRemainingKey, GetMaxSpellChargesRemaining(itemFields->spellChargesRemaining));
|
||||
PushTableValue(luaState, flagsKey, itemFields->flags);
|
||||
PushTableValue(luaState, permanentEnchantIdKey, itemFields->permEnchantmentSlot.id);
|
||||
PushTableValue(luaState, tempEnchantIdKey, itemFields->tempEnchantmentSlot.id);
|
||||
@@ -162,6 +179,7 @@ namespace Nampower {
|
||||
currentData.itemId = itemId;
|
||||
currentData.stackCount = itemFields->stackCount;
|
||||
currentData.duration = itemFields->duration;
|
||||
currentData.spellChargesRemaining = GetMaxSpellChargesRemaining(itemFields->spellChargesRemaining);
|
||||
currentData.flags = itemFields->flags;
|
||||
currentData.permanentEnchantId = itemFields->permEnchantmentSlot.id;
|
||||
currentData.tempEnchantId = itemFields->tempEnchantmentSlot.id;
|
||||
@@ -234,6 +252,7 @@ namespace Nampower {
|
||||
PushTableValue(luaState, itemIdKey, itemId);
|
||||
PushTableValue(luaState, stackCountKey, itemFields->stackCount);
|
||||
PushTableValue(luaState, durationKey, itemFields->duration);
|
||||
PushTableValue(luaState, spellChargesRemainingKey, GetMaxSpellChargesRemaining(itemFields->spellChargesRemaining));
|
||||
PushTableValue(luaState, flagsKey, itemFields->flags);
|
||||
PushTableValue(luaState, permanentEnchantIdKey, itemFields->permEnchantmentSlot.id);
|
||||
PushTableValue(luaState, tempEnchantIdKey, itemFields->tempEnchantmentSlot.id);
|
||||
|
||||
+3
-1
@@ -39,6 +39,7 @@ namespace Nampower {
|
||||
uint32_t itemId;
|
||||
uint32_t stackCount;
|
||||
uint32_t duration;
|
||||
int32_t spellChargesRemaining;
|
||||
uint32_t flags;
|
||||
uint32_t permanentEnchantId;
|
||||
uint32_t tempEnchantId;
|
||||
@@ -47,7 +48,7 @@ namespace Nampower {
|
||||
uint32_t durability;
|
||||
uint32_t maxDurability;
|
||||
|
||||
CachedItemData() : itemId(0), stackCount(0), duration(0), flags(0),
|
||||
CachedItemData() : itemId(0), stackCount(0), duration(0), spellChargesRemaining(0), flags(0),
|
||||
permanentEnchantId(0), tempEnchantId(0),
|
||||
tempEnchantmentTimeLeftMs(0), tempEnchantmentCharges(0),
|
||||
durability(0), maxDurability(0) {}
|
||||
@@ -56,6 +57,7 @@ namespace Nampower {
|
||||
return itemId == other.itemId &&
|
||||
stackCount == other.stackCount &&
|
||||
duration == other.duration &&
|
||||
spellChargesRemaining == other.spellChargesRemaining &&
|
||||
flags == other.flags &&
|
||||
permanentEnchantId == other.permanentEnchantId &&
|
||||
tempEnchantId == other.tempEnchantId &&
|
||||
|
||||
+2
-2
@@ -26,8 +26,8 @@ namespace Nampower {
|
||||
constexpr uint32_t DISENCHANT_QUALITY_PURPLE = 0x04; // Epic
|
||||
|
||||
constexpr uint32_t MAJOR_VERSION = 4;
|
||||
constexpr uint32_t MINOR_VERSION = 1;
|
||||
constexpr uint32_t PATCH_VERSION = 3;
|
||||
constexpr uint32_t MINOR_VERSION = 2;
|
||||
constexpr uint32_t PATCH_VERSION = 0;
|
||||
|
||||
constexpr int32_t LUA_REGISTRYINDEX = -10000;
|
||||
constexpr int32_t LUA_GLOBALSINDEX = -10001;
|
||||
|
||||
Reference in New Issue
Block a user