diff --git a/data/sql/db-world/trasm_world_texts.sql b/data/sql/db-world/trasm_world_texts.sql index 7d2b882..446fce1 100644 --- a/data/sql/db-world/trasm_world_texts.sql +++ b/data/sql/db-world/trasm_world_texts.sql @@ -20,7 +20,8 @@ INSERT INTO `acore_string` (`entry`, `content_default`) VALUES (@STRING_ENTRY+10, 'Invalid name inserted.'), (@STRING_ENTRY+11, 'Showing transmogrifieded items, relog to update the current area.'), (@STRING_ENTRY+12, 'Hiding transmogrifieded items, relog to update the current area.'), -(@STRING_ENTRY+13, 'The selected Item is not suitable for transmogrification.'); +(@STRING_ENTRY+13, 'The selected Item is not suitable for transmogrification.'), +(@STRING_ENTRY+14, 'The selected Item cannot be used for transmogrification of the target player.'); DELETE FROM `command` WHERE `name` IN ('transmog', 'transmog add', 'transmog add set'); INSERT INTO `command` (`name`, `security`, `help`) VALUES diff --git a/src/Transmogrification.h b/src/Transmogrification.h index ebad395..7877891 100644 --- a/src/Transmogrification.h +++ b/src/Transmogrification.h @@ -47,7 +47,8 @@ enum TransmogAcoreStrings // Language.h might have same entries, appears when ex #endif LANG_CMD_TRANSMOG_SHOW = 11111, LANG_CMD_TRANSMOG_HIDE = 11112, - LANG_CMD_TRANSMOG_ADD = 11113, + LANG_CMD_TRANSMOG_ADD_UNSUITABLE = 11113, + LANG_CMD_TRANSMOG_ADD_FORBIDDEN = 11114, }; class Transmogrification diff --git a/src/cs_transmog.cpp b/src/cs_transmog.cpp index 735835a..9bdeef6 100644 --- a/src/cs_transmog.cpp +++ b/src/cs_transmog.cpp @@ -31,21 +31,21 @@ public: ChatCommandTable GetCommands() const override { static ChatCommandTable addCollectionTable = - { - { "set", HandleAddTransmogItemSet, SEC_MODERATOR, Console::No }, - { "", HandleAddTransmogItem, SEC_MODERATOR, Console::No }, - }; + { + { "set", HandleAddTransmogItemSet, SEC_MODERATOR, Console::No }, + { "", HandleAddTransmogItem, SEC_MODERATOR, Console::No }, + }; static ChatCommandTable transmogTable = - { - { "add", addCollectionTable }, - { "", HandleDisableTransMogVisual, SEC_PLAYER, Console::No }, - }; + { + { "add", addCollectionTable }, + { "", HandleDisableTransMogVisual, SEC_PLAYER, Console::No }, + }; static ChatCommandTable commandTable = - { - { "transmog", transmogTable }, - }; + { + { "transmog", transmogTable }, + }; return commandTable; } @@ -90,27 +90,45 @@ public: if (!sTransmogrification->GetTrackUnusableItems() && !sTransmogrification->SuitableForTransmogrification(target, itemTemplate)) { - handler->SendSysMessage(LANG_CMD_TRANSMOG_ADD); + handler->SendSysMessage(LANG_CMD_TRANSMOG_ADD_UNSUITABLE); handler->SetSentErrorMessage(true); return true; } if (itemTemplate->Class != ITEM_CLASS_ARMOR && itemTemplate->Class != ITEM_CLASS_WEAPON) + { + handler->SendSysMessage(LANG_CMD_TRANSMOG_ADD_FORBIDDEN); + handler->SetSentErrorMessage(true); return true; + } uint32 itemId = itemTemplate->ItemId; uint32 accountId = target->GetSession()->GetAccountId(); std::stringstream tempStream; tempStream << std::hex << ItemQualityColors[itemTemplate->Quality]; std::string itemQuality = tempStream.str(); + std::string itemName = itemTemplate->Name1; + std::string nameLink = handler->playerLink(target->GetName()); if (sTransmogrification->AddCollectedAppearance(accountId, itemId)) { + if (!(target->GetPlayerSetting("mod-transmog", SETTING_HIDE_TRANSMOG).value)) { - ChatHandler(target->GetSession()).PSendSysMessage(R"(|c%s|Hitem:%u:0:0:0:0:0:0:0:0|h[%s]|h|r has been added to your appearance collection.)", itemQuality.c_str(), itemId, itemTemplate->Name1.c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(R"(|c%s|Hitem:%u:0:0:0:0:0:0:0:0|h[%s]|h|r has been added to your appearance collection.)", itemQuality.c_str(), itemId, itemName.c_str()); } + + if (target != handler->GetPlayer()) + { + handler->PSendSysMessage(R"(|c%s|Hitem:%u:0:0:0:0:0:0:0:0|h[%s]|h|r has been added to the appearance collection of Player %s.)", itemQuality.c_str(), itemId, itemName.c_str(), nameLink); + } + CharacterDatabase.Execute("INSERT INTO custom_unlocked_appearances (account_id, item_template_id) VALUES ({}, {})", accountId, itemId); } + else + { + handler->PSendSysMessage(R"(Player %s already has item |c%s|Hitem:%u:0:0:0:0:0:0:0:0|h[%s]|h|r in the appearance collection.)", nameLink, itemQuality.c_str(), itemId, itemName.c_str()); + handler->SetSentErrorMessage(true); + } return true; } @@ -142,6 +160,8 @@ public: return false; } + bool added = false; + uint32 error = 0; uint32 accountId = target->GetSession()->GetAccountId(); uint32 itemId; for (uint32 i = 0; i < MAX_ITEM_SET_ITEMS; ++i) @@ -153,25 +173,56 @@ public: if (itemTemplate) { if (!sTransmogrification->GetTrackUnusableItems() && !sTransmogrification->SuitableForTransmogrification(target, itemTemplate)) + { + error = LANG_CMD_TRANSMOG_ADD_UNSUITABLE; continue; + } if (itemTemplate->Class != ITEM_CLASS_ARMOR && itemTemplate->Class != ITEM_CLASS_WEAPON) + { + error = LANG_CMD_TRANSMOG_ADD_FORBIDDEN; continue; + } if (sTransmogrification->AddCollectedAppearance(accountId, itemId)) { CharacterDatabase.Execute("INSERT INTO custom_unlocked_appearances (account_id, item_template_id) VALUES ({}, {})", accountId, itemId); + added = true; } } } } + LOG_DEBUG("module", "Transmog Error {}", error); + // .transmog add set 699 + if (!added && error > 0) + { + handler->SendSysMessage(error); + handler->SetSentErrorMessage(true); + return true; + } + + + int locale = handler->GetSessionDbcLocale(); + std::string setName = set->name[locale]; + std::string nameLink = handler->playerLink(target->GetName()); + + if (!added) + { + handler->PSendSysMessage("Player %s already has ItemSet |cffffffff|Hitemset:%d|h[%s %s]|h|r in the appearance collection.", nameLink, uint32(itemSetId), setName.c_str(), localeNames[locale]); + handler->SetSentErrorMessage(true); + return true; + } + if (!(target->GetPlayerSetting("mod-transmog", SETTING_HIDE_TRANSMOG).value)) { - int locale = handler->GetSessionDbcLocale(); - std::string setName = set->name[locale]; ChatHandler(target->GetSession()).PSendSysMessage("ItemSet |cffffffff|Hitemset:%d|h[%s %s]|h|r has been added to your appearance collection.", uint32(itemSetId), setName.c_str(), localeNames[locale]); } + if (target != handler->GetPlayer()) + { + handler->PSendSysMessage("ItemSet |cffffffff|Hitemset:%d|h[%s %s]|h|r has been added to the appearance collection of Player %s.", uint32(itemSetId), setName.c_str(), localeNames[locale], nameLink); + } + return true; } };