mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 00:48:56 +01:00
Items/Reforge: Partially implemented reforge, still ToDo: Apply real stat modifiers to the player
This commit is contained in:
@@ -115,6 +115,7 @@ DBCStorage <ImportPriceQualityEntry> sImportPriceQualityStore(ImportPriceQu
|
||||
DBCStorage <ImportPriceShieldEntry> sImportPriceShieldStore(ImportPriceShieldfmt);
|
||||
DBCStorage <ImportPriceWeaponEntry> sImportPriceWeaponStore(ImportPriceWeaponfmt);
|
||||
DBCStorage <ItemPriceBaseEntry> sItemPriceBaseStore(ItemPriceBasefmt);
|
||||
DBCStorage <ItemReforgeEntry> sItemReforgeStore(ItemReforgefmt);
|
||||
DBCStorage <ItemArmorQualityEntry> sItemArmorQualityStore(ItemArmorQualityfmt);
|
||||
DBCStorage <ItemArmorShieldEntry> sItemArmorShieldStore(ItemArmorShieldfmt);
|
||||
DBCStorage <ItemArmorTotalEntry> sItemArmorTotalStore(ItemArmorTotalfmt);
|
||||
@@ -402,6 +403,7 @@ void LoadDBCStores(const std::string& dataPath)
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sImportPriceShieldStore, dbcPath, "ImportPriceShield.dbc"); // 15595
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sImportPriceWeaponStore, dbcPath, "ImportPriceWeapon.dbc"); // 15595
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sItemPriceBaseStore, dbcPath, "ItemPriceBase.dbc"); // 15595
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sItemReforgeStore, dbcPath, "ItemReforge.dbc"); // 15595
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sItemBagFamilyStore, dbcPath, "ItemBagFamily.dbc");//14545
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sItemClassStore, dbcPath, "ItemClass.dbc"); // 15595
|
||||
//LoadDBC(dbcCount, availableDbcLocales, bad_dbc_files, sItemDisplayInfoStore, dbcPath, "ItemDisplayInfo.dbc"); -- not used currently
|
||||
|
||||
@@ -126,6 +126,7 @@ extern DBCStorage <ImportPriceQualityEntry> sImportPriceQualityStore;
|
||||
extern DBCStorage <ImportPriceShieldEntry> sImportPriceShieldStore;
|
||||
extern DBCStorage <ImportPriceWeaponEntry> sImportPriceWeaponStore;
|
||||
extern DBCStorage <ItemPriceBaseEntry> sItemPriceBaseStore;
|
||||
extern DBCStorage <ItemReforgeEntry> sItemReforgeStore;
|
||||
extern DBCStorage <ItemArmorQualityEntry> sItemArmorQualityStore;
|
||||
extern DBCStorage <ItemArmorShieldEntry> sItemArmorShieldStore;
|
||||
extern DBCStorage <ItemArmorTotalEntry> sItemArmorTotalStore;
|
||||
|
||||
@@ -1192,6 +1192,15 @@ struct ItemPriceBaseEntry
|
||||
float WeaponFactor; // 4 Price factor for weapons
|
||||
};
|
||||
|
||||
struct ItemReforgeEntry
|
||||
{
|
||||
uint32 Id;
|
||||
uint32 FinalStat;
|
||||
float FinalMultiplier;
|
||||
uint32 SourceStat;
|
||||
float SourceMultiplier;
|
||||
};
|
||||
|
||||
// common struct for:
|
||||
// ItemDamageAmmo.dbc
|
||||
// ItemDamageOneHand.dbc
|
||||
|
||||
@@ -83,6 +83,7 @@ const char ImportPriceQualityfmt[]="nf";
|
||||
const char ImportPriceShieldfmt[]="nf";
|
||||
const char ImportPriceWeaponfmt[]="nf";
|
||||
const char ItemPriceBasefmt[]="diff";
|
||||
const char ItemReforgefmt[]="nifif";
|
||||
const char ItemBagFamilyfmt[]="nx";
|
||||
const char ItemArmorQualityfmt[]="nfffffffi";
|
||||
const char ItemArmorShieldfmt[]="nifffffff";
|
||||
|
||||
@@ -1424,7 +1424,7 @@ uint32 Item::GetSellPrice(bool& normalSellPrice) const
|
||||
}
|
||||
}
|
||||
|
||||
uint32 Item::GetTransmogrifyCost() const
|
||||
uint32 Item::GetSpecialPrice(uint32 minimumPrice) const
|
||||
{
|
||||
ItemTemplate const* proto = GetTemplate();
|
||||
uint32 cost = 0;
|
||||
@@ -1453,8 +1453,8 @@ uint32 Item::GetTransmogrifyCost() const
|
||||
cost = proto->SellPrice;
|
||||
}
|
||||
|
||||
if (cost < 10000)
|
||||
cost = 10000;
|
||||
if (cost < minimumPrice)
|
||||
cost = minimumPrice;
|
||||
|
||||
return cost;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ enum EnchantmentSlot
|
||||
BONUS_ENCHANTMENT_SLOT = 5,
|
||||
PRISMATIC_ENCHANTMENT_SLOT = 6, // added at apply special permanent enchantment
|
||||
//TODO: 7,
|
||||
//TODO: 8,
|
||||
REFORGE_ENCHANTMENT_SLOT = 8,
|
||||
TRANSMOGRIFY_ENCHANTMENT_SLOT = 9,
|
||||
MAX_INSPECTED_ENCHANTMENT_SLOT = 10,
|
||||
|
||||
@@ -350,7 +350,7 @@ class Item : public Object
|
||||
bool CanBeTransmogrified() const;
|
||||
bool CanTransmogrify() const;
|
||||
static bool CanTransmogrifyItemWithItem(Item const* transmogrified, Item const* transmogrifier);
|
||||
uint32 GetTransmogrifyCost() const;
|
||||
uint32 GetSpecialPrice(uint32 minimumPrice = 10000) const;
|
||||
|
||||
uint32 GetVisibleEntry() const
|
||||
{
|
||||
|
||||
@@ -1617,7 +1617,7 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData)
|
||||
itemTransmogrifier->SetNotRefundable(player);
|
||||
itemTransmogrifier->ClearSoulboundTradeable(player);
|
||||
|
||||
cost += itemTransmogrified->GetTransmogrifyCost();
|
||||
cost += itemTransmogrified->GetSpecialPrice();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1631,3 +1631,83 @@ void WorldSession::HandleTransmogrifyItems(WorldPacket& recvData)
|
||||
delete[] newEntries;
|
||||
delete[] slots;
|
||||
}
|
||||
|
||||
void WorldSession::SendReforgeResult(bool success)
|
||||
{
|
||||
WorldPacket data(SMSG_REFORGE_RESULT, 1);
|
||||
data.WriteBit(success);
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::HandleReforgeItemOpcode(WorldPacket& recvData)
|
||||
{
|
||||
uint32 slot, reforgeEntry;
|
||||
ObjectGuid guid;
|
||||
uint32 bag;
|
||||
Player* player = GetPlayer();
|
||||
|
||||
recvData >> reforgeEntry >> slot >> bag;
|
||||
|
||||
guid[2] = recvData.ReadBit();
|
||||
guid[6] = recvData.ReadBit();
|
||||
guid[3] = recvData.ReadBit();
|
||||
guid[4] = recvData.ReadBit();
|
||||
guid[1] = recvData.ReadBit();
|
||||
guid[0] = recvData.ReadBit();
|
||||
guid[7] = recvData.ReadBit();
|
||||
guid[5] = recvData.ReadBit();
|
||||
|
||||
recvData.ReadByteSeq(guid[2]);
|
||||
recvData.ReadByteSeq(guid[3]);
|
||||
recvData.ReadByteSeq(guid[6]);
|
||||
recvData.ReadByteSeq(guid[4]);
|
||||
recvData.ReadByteSeq(guid[1]);
|
||||
recvData.ReadByteSeq(guid[0]);
|
||||
recvData.ReadByteSeq(guid[7]);
|
||||
recvData.ReadByteSeq(guid[5]);
|
||||
|
||||
if (!player->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_REFORGER))
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleReforgeItemOpcode - Unit (GUID: %u) not found or player can't interact with it.", GUID_LOPART(guid));
|
||||
SendReforgeResult(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Item* item = player->GetItemByPos(bag, slot);
|
||||
|
||||
if (!item)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an invalid/non-existant item.", player->GetGUIDLow(), player->GetName());
|
||||
SendReforgeResult(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!reforgeEntry)
|
||||
{
|
||||
// Reset the item
|
||||
item->ClearEnchantment(REFORGE_ENCHANTMENT_SLOT);
|
||||
SendReforgeResult(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sItemReforgeStore.LookupEntry(reforgeEntry))
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleReforgeItemOpcode - Player (Guid: %u Name: %s) tried to reforge an item with invalid reforge entry (%u).", player->GetGUIDLow(), player->GetName(), reforgeEntry);
|
||||
SendReforgeResult(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player->HasEnoughMoney(item->GetSpecialPrice())) // cheating
|
||||
{
|
||||
SendReforgeResult(false);
|
||||
return;
|
||||
}
|
||||
|
||||
player->ModifyMoney(-int64(item->GetSpecialPrice()));
|
||||
|
||||
item->SetEnchantment(REFORGE_ENCHANTMENT_SLOT, reforgeEntry, 0, 0);
|
||||
|
||||
SendReforgeResult(true);
|
||||
|
||||
// ToDo: Apply and remove the destination/source stats to the player
|
||||
}
|
||||
|
||||
@@ -532,6 +532,8 @@ void InitOpcodes()
|
||||
//DEFINE_OPCODE_HANDLER(CMSG_REDIRECTION_AUTH_PROOF, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
|
||||
//DEFINE_OPCODE_HANDLER(CMSG_REDIRECTION_FAILED, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
|
||||
//DEFINE_OPCODE_HANDLER(CMSG_REFER_A_FRIEND, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
|
||||
DEFINE_OPCODE_HANDLER(CMSG_REFORGE_ITEM, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleReforgeItemOpcode );
|
||||
DEFINE_OPCODE_HANDLER(SMSG_REFORGE_RESULT, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
|
||||
//DEFINE_OPCODE_HANDLER(CMSG_REMOVE_GLYPH, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleRemoveGlyph );
|
||||
//DEFINE_OPCODE_HANDLER(CMSG_REPAIR_ITEM, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleRepairItemOpcode );
|
||||
//DEFINE_OPCODE_HANDLER(CMSG_REPOP_REQUEST, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleRepopRequestOpcode );
|
||||
|
||||
@@ -921,6 +921,10 @@ class WorldSession
|
||||
|
||||
// Transmogrification
|
||||
void HandleTransmogrifyItems(WorldPacket& recvData);
|
||||
|
||||
// Reforge
|
||||
void HandleReforgeItemOpcode(WorldPacket& recvData);
|
||||
void SendReforgeResult(bool success);
|
||||
|
||||
// Miscellaneous
|
||||
void HandleSpellClick(WorldPacket& recv_data);
|
||||
|
||||
Reference in New Issue
Block a user