mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-21 04:02:48 +00:00
feat(loot): rewards, purchases, mail and trades say where items came from
The other item sources live marked in AddItemToInventoryClientSync's extra info, with the keys and values live sent: - mission and achievement rewards: _Metric_Mission_ID_Int and source LOT 1, the player (225 of 225 live rewards) - activity rewards: _Metric_Activity_ID_Int and the activity object's LOT - vendor purchases: the vendor's LOT and _Metric_Currency_Delta_Int, the coins paid as a negative number (left out when the item costs no coins) - mail attachments: _Metric_Mail_ID_Int64 - traded items: _Metric_Transaction_ID_Int64, the trade's ID Loot::GiveLoot gains overloads that pass them on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -523,14 +523,22 @@ Loot::Return Loot::RollLootMatrix(Entity* player, uint32_t matrixIndex) {
|
||||
}
|
||||
|
||||
void Loot::GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceType lootSourceType) {
|
||||
GiveLoot(player, matrixIndex, lootSourceType, LootMetrics{});
|
||||
}
|
||||
|
||||
void Loot::GiveLoot(Entity* player, const Loot::Return& result, eLootSourceType lootSourceType) {
|
||||
GiveLoot(player, result, lootSourceType, LootMetrics{});
|
||||
}
|
||||
|
||||
void Loot::GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceType lootSourceType, const LootMetrics& metrics) {
|
||||
player = player->GetOwner(); // If the owner is overwritten, we collect that here
|
||||
|
||||
const auto result = RollLootMatrix(player, matrixIndex);
|
||||
|
||||
GiveLoot(player, result, lootSourceType);
|
||||
GiveLoot(player, result, lootSourceType, metrics);
|
||||
}
|
||||
|
||||
void Loot::GiveLoot(Entity* player, const Loot::Return& result, eLootSourceType lootSourceType) {
|
||||
void Loot::GiveLoot(Entity* player, const Loot::Return& result, eLootSourceType lootSourceType, const LootMetrics& metrics) {
|
||||
player = player->GetOwner(); // if the owner is overwritten, we collect that here
|
||||
|
||||
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||
@@ -539,7 +547,7 @@ void Loot::GiveLoot(Entity* player, const Loot::Return& result, eLootSourceType
|
||||
return;
|
||||
|
||||
for (const auto& pair : result) {
|
||||
inventoryComponent->AddItem(pair.first, pair.second, lootSourceType);
|
||||
inventoryComponent->AddItem(pair.first, pair.second, lootSourceType, eInventoryType::INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, eInventoryType::INVALID, 0, false, -1, metrics);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,7 +585,11 @@ void Loot::GiveActivityLoot(Entity* player, const LWOOBJID source, uint32_t acti
|
||||
|
||||
const auto [minCoins, maxCoins] = GetActivityCoinRange(*selectedReward);
|
||||
|
||||
GiveLoot(player, selectedReward->LootMatrixIndex, eLootSourceType::ACTIVITY);
|
||||
// Live sent the activity's ID and the activity object's LOT with each reward item
|
||||
LootMetrics metrics{};
|
||||
metrics.activityId = static_cast<int32_t>(activityID);
|
||||
if (const auto* const sourceEntity = Game::entityManager->GetEntity(source)) metrics.sourceLot = sourceEntity->GetLOT();
|
||||
GiveLoot(player, selectedReward->LootMatrixIndex, eLootSourceType::ACTIVITY, metrics);
|
||||
|
||||
uint32_t coins = static_cast<uint32_t>(minCoins + GeneralUtils::GenerateRandomNumber<float>(0, 1) * (maxCoins - minCoins));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user