mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-13 03:22:40 -04:00
Core/Items: Added loading and saving transmogrification.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
UPDATE `item_instance` SET `enchantments` = REPLACE(`enchantments`,' ',' ');
|
||||
UPDATE `item_instance` SET `enchantments` = CONCAT(TRIM(`enchantments`),' ');
|
||||
|
||||
UPDATE `item_instance` SET `enchantments` = CONCAT(
|
||||
SUBSTRING_INDEX(`enchantments`, ' ', 7*3),
|
||||
' 0 0 0 0 0 0 0 0 0 ',
|
||||
SUBSTRING_INDEX(`enchantments`, ' ', -(12-7)*3 - 1))
|
||||
WHERE (LENGTH(`enchantments`) - LENGTH(REPLACE(`enchantments`, ' ', ''))) = 12*3;
|
||||
|
||||
UPDATE `item_instance` SET `enchantments` = REPLACE(`enchantments`,' ',' ');
|
||||
UPDATE `item_instance` SET `enchantments` = CONCAT(TRIM(`enchantments`),' ');
|
||||
@@ -164,14 +164,15 @@ enum EnchantmentSlot
|
||||
PRISMATIC_ENCHANTMENT_SLOT = 6, // added at apply special permanent enchantment
|
||||
//TODO: 7,
|
||||
//TODO: 8,
|
||||
MAX_INSPECTED_ENCHANTMENT_SLOT = 9,
|
||||
TRANSMOGRIFY_ENCHANTMENT_SLOT = 9,
|
||||
MAX_INSPECTED_ENCHANTMENT_SLOT = 10,
|
||||
|
||||
PROP_ENCHANTMENT_SLOT_0 = 7, // used with RandomSuffix
|
||||
PROP_ENCHANTMENT_SLOT_1 = 8, // used with RandomSuffix
|
||||
PROP_ENCHANTMENT_SLOT_2 = 9, // used with RandomSuffix and RandomProperty
|
||||
PROP_ENCHANTMENT_SLOT_3 = 10, // used with RandomProperty
|
||||
PROP_ENCHANTMENT_SLOT_4 = 11, // used with RandomProperty
|
||||
MAX_ENCHANTMENT_SLOT = 12
|
||||
PROP_ENCHANTMENT_SLOT_0 = 10, // used with RandomSuffix
|
||||
PROP_ENCHANTMENT_SLOT_1 = 11, // used with RandomSuffix
|
||||
PROP_ENCHANTMENT_SLOT_2 = 12, // used with RandomSuffix and RandomProperty
|
||||
PROP_ENCHANTMENT_SLOT_3 = 13, // used with RandomProperty
|
||||
PROP_ENCHANTMENT_SLOT_4 = 14, // used with RandomProperty
|
||||
MAX_ENCHANTMENT_SLOT = 15
|
||||
};
|
||||
|
||||
#define MAX_VISIBLE_ITEM_OFFSET 2 // 2 fields per visible item (entry+enchantment)
|
||||
@@ -350,6 +351,13 @@ class Item : public Object
|
||||
bool CanTransmogrify() const;
|
||||
static bool CanTransmogrifyItemWithItem(Item const* transmogrified, Item const* transmogrifier);
|
||||
|
||||
uint32 GetVisibleEntry() const
|
||||
{
|
||||
if (uint32 transmogrification = GetEnchantmentId(TRANSMOGRIFY_ENCHANTMENT_SLOT))
|
||||
return transmogrification;
|
||||
return GetEntry();
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_text;
|
||||
uint8 m_slot;
|
||||
|
||||
@@ -12357,7 +12357,7 @@ void Player::SetVisibleItemSlot(uint8 slot, Item* pItem)
|
||||
{
|
||||
if (pItem)
|
||||
{
|
||||
SetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + (slot * 2), pItem->GetEntry());
|
||||
SetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + (slot * 2), pItem->GetVisibleEntry());
|
||||
SetUInt16Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (slot * 2), 0, pItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT));
|
||||
SetUInt16Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (slot * 2), 1, pItem->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT));
|
||||
}
|
||||
@@ -25717,7 +25717,7 @@ uint8 Player::AddVoidStorageItem(const VoidStorageItem& item)
|
||||
GetSession()->SendVoidStorageTransferResult(VOID_TRANSFER_ERROR_FULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
_voidStorageItems[slot] = new VoidStorageItem(item.ItemId, item.ItemEntry,
|
||||
item.CreatorGuid, item.ItemRandomPropertyId, item.ItemSuffixFactor);
|
||||
return slot;
|
||||
|
||||
@@ -746,7 +746,7 @@ void WorldSession::SendListInventory(uint64 vendorGuid)
|
||||
VendorItemData const* vendorItems = vendor->GetVendorItems();
|
||||
uint8 rawItemCount = vendorItems ? vendorItems->GetItemCount() : 0;
|
||||
|
||||
//if (rawItemCount > 300),
|
||||
//if (rawItemCount > 300),
|
||||
// rawItemCount = 300; // client cap but uint8 max value is 255
|
||||
|
||||
ByteBuffer itemsData(32 * rawItemCount);
|
||||
@@ -783,7 +783,7 @@ void WorldSession::SendListInventory(uint64 vendorGuid)
|
||||
if (leftInStock == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int32 price = vendorItem->IsGoldRequired(itemTemplate) ? uint32(floor(itemTemplate->BuyPrice * discountMod)) : 0;
|
||||
uint32 leftInStock = !vendorItem->maxcount ? 0xFFFFFFFF : vendor->GetVendorItemCurrentCount(vendorItem);
|
||||
|
||||
@@ -1464,7 +1464,6 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData)
|
||||
Player* player = GetPlayer();
|
||||
|
||||
// Read data
|
||||
|
||||
uint32 count = recvData.ReadBits(22);
|
||||
|
||||
if (count < EQUIPMENT_SLOT_START || count >= EQUIPMENT_SLOT_END)
|
||||
@@ -1477,7 +1476,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData)
|
||||
ObjectGuid* itemGuids = new ObjectGuid[count];
|
||||
uint32* newEntries = new uint32[count];
|
||||
uint32* slots = new uint32[count];
|
||||
|
||||
|
||||
for (uint8 i = 0; i < count; ++i)
|
||||
{
|
||||
itemGuids[i][0] = recvData.ReadBit();
|
||||
@@ -1592,8 +1591,8 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData)
|
||||
|
||||
if (!newEntries[i]) // reset look
|
||||
{
|
||||
player->SetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + (slots[i] * 2), itemTransmogrified->GetEntry());
|
||||
itemTransmogrified->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_10_1, 0);
|
||||
itemTransmogrified->ClearEnchantment(TRANSMOGRIFY_ENCHANTMENT_SLOT);
|
||||
player->SetVisibleItemSlot(slots[i], itemTransmogrified);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1604,9 +1603,8 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
// All okay, proceed
|
||||
|
||||
player->SetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + (slots[i] * 2), newEntries[i]);
|
||||
itemTransmogrified->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_10_1, newEntries[i]);
|
||||
itemTransmogrified->SetEnchantment(TRANSMOGRIFY_ENCHANTMENT_SLOT, newEntries[i], 0, 0);
|
||||
player->SetVisibleItemSlot(slots[i], itemTransmogrified);
|
||||
|
||||
itemTransmogrified->UpdatePlayedTime(player);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user