New roll for item action (#1482)

* New roll for item action

* Add general roll command as well.

* Update ChatCommandHandlerStrategy.cpp

Add accidental removal of glyph equip

---------

Co-authored-by: bash <31279994+hermensbas@users.noreply.github.com>
This commit is contained in:
Keleborn
2025-08-01 12:44:52 -07:00
committed by GitHub
parent e950f65a83
commit a1dd6f6fc5
6 changed files with 51 additions and 0 deletions

View File

@@ -224,3 +224,37 @@ bool RollUniqueCheck(ItemTemplate const* proto, Player* bot)
}
return false; // Item is not equipped or in bags, roll for it
}
bool RollAction::Execute(Event event)
{
std::string link = event.getParam();
if (link.empty())
{
bot->DoRandomRoll(0,100);
return false;
}
ItemIds itemIds = chat->parseItems(link);
if (itemIds.empty())
return false;
uint32 itemId = *itemIds.begin();
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId);
if (!proto)
{
return false;
}
std::string itemUsageParam;
itemUsageParam = std::to_string(itemId);
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", itemUsageParam);
switch (proto->Class)
{
case ITEM_CLASS_WEAPON:
case ITEM_CLASS_ARMOR:
if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_BAD_EQUIP)
{
bot->DoRandomRoll(0,100);
}
}
return true;
}