aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2021-05-11 18:25:22 +0200
committerShauren <shauren.trinity@gmail.com>2021-05-11 18:25:22 +0200
commitf072bc4ca1375805691c5f98e7def74aa8ae9f31 (patch)
treeeea2cc8c4b927dbfb210e5298a805c916a088b6b /src
parent8a551d598de0cc8a036740328676195cdfff71a4 (diff)
Core/Commands: Add ItemContext argument to .additem and .additemset commands
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index e3d62a42dd1..0b3547670bc 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -1313,12 +1313,26 @@ public:
std::vector<int32> bonusListIDs;
char const* bonuses = strtok(nullptr, " ");
+ char const* context = strtok(nullptr, " ");
+
// semicolon separated bonuslist ids (parse them after all arguments are extracted by strtok!)
if (bonuses)
{
Tokenizer tokens(bonuses, ';');
for (char const* token : tokens)
- bonusListIDs.push_back(atoul(token));
+ if (int32 bonusListId = atoi(token))
+ bonusListIDs.push_back(bonusListId);
+ }
+
+ ItemContext itemContext = ItemContext::NONE;
+ if (context)
+ {
+ itemContext = ItemContext(atoul(context));
+ if (itemContext != ItemContext::NONE && itemContext < ItemContext::Max)
+ {
+ std::set<uint32> contextBonuses = sDB2Manager.GetDefaultItemBonusTree(itemId, itemContext);
+ bonusListIDs.insert(bonusListIDs.begin(), contextBonuses.begin(), contextBonuses.end());
+ }
}
Player* player = handler->GetSession()->GetPlayer();
@@ -1360,7 +1374,7 @@ public:
return false;
}
- Item* item = playerTarget->StoreNewItem(dest, itemId, true, GenerateItemRandomBonusListId(itemId), GuidSet(), ItemContext::NONE, bonusListIDs);
+ Item* item = playerTarget->StoreNewItem(dest, itemId, true, GenerateItemRandomBonusListId(itemId), GuidSet(), itemContext, bonusListIDs);
// remove binding (let GM give it to another player later)
if (player == playerTarget)
@@ -1403,6 +1417,8 @@ public:
std::vector<int32> bonusListIDs;
char const* bonuses = strtok(nullptr, " ");
+ char const* context = strtok(nullptr, " ");
+
// semicolon separated bonuslist ids (parse them after all arguments are extracted by strtok!)
if (bonuses)
{
@@ -1411,6 +1427,10 @@ public:
bonusListIDs.push_back(atoul(token));
}
+ ItemContext itemContext = ItemContext::NONE;
+ if (context)
+ itemContext = ItemContext(atoul(context));
+
Player* player = handler->GetSession()->GetPlayer();
Player* playerTarget = handler->getSelectedPlayer();
if (!playerTarget)
@@ -1429,7 +1449,14 @@ public:
InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itr->second.GetId(), 1);
if (msg == EQUIP_ERR_OK)
{
- Item* item = playerTarget->StoreNewItem(dest, itr->second.GetId(), true, {}, GuidSet(), ItemContext::NONE, bonusListIDs);
+ std::vector<int32> bonusListIDsForItem = bonusListIDs; // copy, bonuses for each depending on context might be different for each item
+ if (itemContext != ItemContext::NONE && itemContext < ItemContext::Max)
+ {
+ std::set<uint32> contextBonuses = sDB2Manager.GetDefaultItemBonusTree(itr->second.GetId(), itemContext);
+ bonusListIDsForItem.insert(bonusListIDs.begin(), contextBonuses.begin(), contextBonuses.end());
+ }
+
+ Item* item = playerTarget->StoreNewItem(dest, itr->second.GetId(), true, {}, GuidSet(), itemContext, bonusListIDsForItem);
// remove binding (let GM give it to another player later)
if (player == playerTarget)