title: Reforging (Rochet2) to AzerothCore
body: <p>Does anyone has already successfully added <a href="https://github.com/Rochet2/TrinityCore/tree/reforging_3.3.5/src/server/scripts/Custom/Reforging" rel="nofollow noreferrer">Rochet2's Reforging script</a> on <a href="https://github.com/azerothcore/azerothcore-wotlk" rel="nofollow noreferrer">AC</a> ?
  Mine works but not completely. 
  On character login the script should re-apply bonuses on reforged (&amp; equipped) items, but it seems "<strong>player->GetItemByGuid()</strong>" can't find the requested item, so it's returning nothing.</p>
  
  <p>TrinityCore code (works) : </p>
  
  <pre><code>uint32 lowGUID = (*result)[0].GetUInt32();
  Item* invItem = player-&gt;GetItemByGuid(ObjectGuid(HighGuid::Item, 0, lowGUID));
  
  if (invItem) 
      player-&gt;_ApplyItemMods(invItem, invItem-&gt;GetSlot(), false);             
  
  ReforgeData&amp; data = player-&gt;reforgeMap[lowGUID];
  data.increase = (*result)[1].GetUInt32();
  data.decrease = (*result)[2].GetUInt32();
  data.stat_value = (*result)[3].GetInt32();
  if (invItem)
       player-&gt;_ApplyItemMods(invItem, invItem-&gt;GetSlot(), true);
  </code></pre>
  
  <p>AzerothCore code (works, but "if (invItem)" condition never satisfied.</p>
  
  <pre><code>uint32 lowGUID = (*result)[0].GetUInt32();
  Item* invItem = player-&gt;GetItemByGuid((uint64) MAKE_NEW_GUID(HIGHGUID_ITEM, 0, lowGUID));
  
  if (invItem /*&amp;&amp; invItem-&gt;IsEquipped()*/)
        player-&gt;_ApplyItemMods(invItem, invItem-&gt;GetSlot(), false); 
  
  ReforgeData&amp; data = player-&gt;reforgeMap[lowGUID];
  data.increase = (*result)[1].GetUInt32();
  data.decrease = (*result)[2].GetUInt32();
  data.stat_value = (*result)[3].GetInt32();
  if (invItem /*&amp;&amp; invItem-&gt;IsEquipped()*/)
        player-&gt;_ApplyItemMods(invItem, invItem-&gt;GetSlot(), true);
  </code></pre>
  
  <p><strong>MAKE_NEW_GUID()</strong> returns something that looks like a guid. </p>
  
  <p>But I don't know why "<strong>player->GetItemByGuid()</strong>" can't find the item.</p>