Shard_MW
Shard_MW

Reputation: 123

Reforging (Rochet2) to AzerothCore

Does anyone has already successfully added Rochet2's Reforging script on AC ? Mine works but not completely. On character login the script should re-apply bonuses on reforged (& equipped) items, but it seems "player->GetItemByGuid()" can't find the requested item, so it's returning nothing.

TrinityCore code (works) :

uint32 lowGUID = (*result)[0].GetUInt32();
Item* invItem = player->GetItemByGuid(ObjectGuid(HighGuid::Item, 0, lowGUID));

if (invItem) 
    player->_ApplyItemMods(invItem, invItem->GetSlot(), false);             

ReforgeData& data = player->reforgeMap[lowGUID];
data.increase = (*result)[1].GetUInt32();
data.decrease = (*result)[2].GetUInt32();
data.stat_value = (*result)[3].GetInt32();
if (invItem)
     player->_ApplyItemMods(invItem, invItem->GetSlot(), true);

AzerothCore code (works, but "if (invItem)" condition never satisfied.

uint32 lowGUID = (*result)[0].GetUInt32();
Item* invItem = player->GetItemByGuid((uint64) MAKE_NEW_GUID(HIGHGUID_ITEM, 0, lowGUID));

if (invItem /*&& invItem->IsEquipped()*/)
      player->_ApplyItemMods(invItem, invItem->GetSlot(), false); 

ReforgeData& data = player->reforgeMap[lowGUID];
data.increase = (*result)[1].GetUInt32();
data.decrease = (*result)[2].GetUInt32();
data.stat_value = (*result)[3].GetInt32();
if (invItem /*&& invItem->IsEquipped()*/)
      player->_ApplyItemMods(invItem, invItem->GetSlot(), true);

MAKE_NEW_GUID() returns something that looks like a guid.

But I don't know why "player->GetItemByGuid()" can't find the item.

Upvotes: 2

Views: 531

Answers (1)

Rochet2
Rochet2

Reputation: 1156

The order of arguments to MAKE_NEW_GUID is different from ObjectGuid constructor. So since your arguments are in wrong order then the result is also wrong and item is not found. See the definition and use of MAKE_NEW_GUID for the correct order of arguments.

Upvotes: 2

Related Questions