feat: Add appearance collection add item command

This commit is contained in:
Gozzim
2022-05-15 18:07:27 +02:00
parent dfa78ae5a4
commit f8fd0e0364
3 changed files with 64 additions and 5 deletions

View File

@@ -5,7 +5,7 @@ INSERT INTO `npc_text` (`ID`, `text0_0`) VALUES
(@TEXT_ID+1, 'You can save your own transmogrification sets.\r\n\r\nTo save, first you must transmogrify your equipped items.\r\nThen when you go to the set management menu and go to save set menu,\r\nall items you have transmogrified are displayed so you see what you are saving.\r\nIf you think the set is fine, you can click to save the set and name it as you wish.\r\n\r\nTo use a set you can click the saved set in the set management menu and then select use set.\r\nIf the set has a transmogrification for an item that is already transmogrified, the old transmogrification is lost.\r\nNote that same transmogrification restrictions apply when trying to use a set as in normal transmogrification.\r\n\r\nTo delete a set you can go to the set\'s menu and select delete set.'); (@TEXT_ID+1, 'You can save your own transmogrification sets.\r\n\r\nTo save, first you must transmogrify your equipped items.\r\nThen when you go to the set management menu and go to save set menu,\r\nall items you have transmogrified are displayed so you see what you are saving.\r\nIf you think the set is fine, you can click to save the set and name it as you wish.\r\n\r\nTo use a set you can click the saved set in the set management menu and then select use set.\r\nIf the set has a transmogrification for an item that is already transmogrified, the old transmogrification is lost.\r\nNote that same transmogrification restrictions apply when trying to use a set as in normal transmogrification.\r\n\r\nTo delete a set you can go to the set\'s menu and select delete set.');
SET @STRING_ENTRY := 11100; SET @STRING_ENTRY := 11100;
DELETE FROM `acore_string` WHERE `entry` IN (@STRING_ENTRY+0,@STRING_ENTRY+1,@STRING_ENTRY+2,@STRING_ENTRY+3,@STRING_ENTRY+4,@STRING_ENTRY+5,@STRING_ENTRY+6,@STRING_ENTRY+7,@STRING_ENTRY+8,@STRING_ENTRY+9,@STRING_ENTRY+10, @STRING_ENTRY+11, @STRING_ENTRY+12); DELETE FROM `acore_string` WHERE `entry` IN (@STRING_ENTRY+0,@STRING_ENTRY+1,@STRING_ENTRY+2,@STRING_ENTRY+3,@STRING_ENTRY+4,@STRING_ENTRY+5,@STRING_ENTRY+6,@STRING_ENTRY+7,@STRING_ENTRY+8,@STRING_ENTRY+9,@STRING_ENTRY+10, @STRING_ENTRY+11, @STRING_ENTRY+12, @STRING_ENTRY+13);
INSERT INTO `acore_string` (`entry`, `content_default`) VALUES INSERT INTO `acore_string` (`entry`, `content_default`) VALUES
(@STRING_ENTRY+0, 'Item successfully transmogrified.'), (@STRING_ENTRY+0, 'Item successfully transmogrified.'),
(@STRING_ENTRY+1, 'Equipment slot is empty.'), (@STRING_ENTRY+1, 'Equipment slot is empty.'),
@@ -19,8 +19,10 @@ INSERT INTO `acore_string` (`entry`, `content_default`) VALUES
(@STRING_ENTRY+9, 'No transmogrification found.'), (@STRING_ENTRY+9, 'No transmogrification found.'),
(@STRING_ENTRY+10, 'Invalid name inserted.'), (@STRING_ENTRY+10, 'Invalid name inserted.'),
(@STRING_ENTRY+11, 'Showing transmogrifieded items, relog to update the current area.'), (@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+12, 'Hiding transmogrifieded items, relog to update the current area.'),
(@STRING_ENTRY+13, 'The selected Item is not suitable for transmogrification.');
DELETE FROM `command` WHERE `name` IN ('transmog'); DELETE FROM `command` WHERE `name` IN ('transmog', 'transmog add');
INSERT INTO `command` (`name`, `security`, `help`) VALUES INSERT INTO `command` (`name`, `security`, `help`) VALUES
('transmog', 0, 'Syntax: .transmog <on/off>\nAllows seeing transmogrified items and the transmogrifier NPC.'); ('transmog', 0, 'Syntax: .transmog <on/off>\nAllows seeing transmogrified items and the transmogrifier NPC.'),
('transmog add', 1, 'Syntax: .transmog add $player $item\nAdds an item to a player\'s appearance collection.');

View File

@@ -47,6 +47,7 @@ enum TransmogAcoreStrings // Language.h might have same entries, appears when ex
#endif #endif
LANG_CMD_TRANSMOG_SHOW = 11111, LANG_CMD_TRANSMOG_SHOW = 11111,
LANG_CMD_TRANSMOG_HIDE = 11112, LANG_CMD_TRANSMOG_HIDE = 11112,
LANG_CMD_TRANSMOG_ADD = 11113,
}; };
class Transmogrification class Transmogrification

View File

@@ -30,9 +30,15 @@ public:
ChatCommandTable GetCommands() const override ChatCommandTable GetCommands() const override
{ {
static ChatCommandTable transmogTable =
{
{ "add", HandleAddTransmogItem, SEC_MODERATOR, Console::No },
{ "", HandleDisableTransMogVisual, SEC_PLAYER, Console::No },
};
static ChatCommandTable commandTable = static ChatCommandTable commandTable =
{ {
{ "transmog", HandleDisableTransMogVisual, SEC_PLAYER, Console::No }, { "transmog", transmogTable },
}; };
return commandTable; return commandTable;
@@ -56,6 +62,56 @@ public:
player->UpdateObjectVisibility(); player->UpdateObjectVisibility();
return true; return true;
} }
static bool HandleAddTransmogItem(ChatHandler* handler, Optional <PlayerIdentifier> player, ItemTemplate const* itemTemplate)
{
if (!sTransmogrification->GetUseCollectionSystem())
return true;
if (!sObjectMgr->GetItemTemplate(itemTemplate->ItemId))
{
handler->PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemTemplate->ItemId);
handler->SetSentErrorMessage(true);
return false;
}
if (!player)
player = PlayerIdentifier::FromTargetOrSelf(handler);
if (!player || !player->IsConnected())
return false;
Player* target = player->GetConnectedPlayer();
if (!sTransmogrification->GetTrackUnusableItems() && !sTransmogrification->SuitableForTransmogrification(target, itemTemplate))
{
handler->SendSysMessage(LANG_CMD_TRANSMOG_ADD);
handler->SetSentErrorMessage(true);
return true;
}
if (itemTemplate->Class != ITEM_CLASS_ARMOR && itemTemplate->Class != ITEM_CLASS_WEAPON)
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 query = "SELECT account_id, item_template_id FROM custom_unlocked_appearances WHERE account_id = " + std::to_string(accountId) + " AND item_template_id = " + std::to_string(itemId);
target->GetSession()->GetQueryProcessor().AddCallback(CharacterDatabase.AsyncQuery(query).WithCallback([=](QueryResult result)
{
if (!result)
{
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());
}
CharacterDatabase.Execute("INSERT INTO custom_unlocked_appearances (account_id, item_template_id) VALUES ({}, {})", accountId, itemId);
}
}));
return true;
}
}; };
void AddSC_transmog_commandscript() void AddSC_transmog_commandscript()