mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
7a051afd97
Added support for Items to have a loot source attached to them when dropped or rolled. This fixes the issue where achievements would give the item before it appeared in the achievement window.
18 lines
637 B
C++
18 lines
637 B
C++
#include "NjScrollChestServer.h"
|
|
#include "InventoryComponent.h"
|
|
|
|
void NjScrollChestServer::OnUse(Entity *self, Entity *user) {
|
|
const auto keyLOT = self->GetVar<LOT>(u"KeyNum");
|
|
const auto rewardItemLOT = self->GetVar<LOT>(u"openItemID");
|
|
|
|
auto* playerInventory = user->GetComponent<InventoryComponent>();
|
|
if (playerInventory != nullptr && playerInventory->GetLotCount(keyLOT) == 1) {
|
|
|
|
// Check for the key and remove
|
|
playerInventory->RemoveItem(keyLOT, 1);
|
|
|
|
// Reward the player with the item set
|
|
playerInventory->AddItem(rewardItemLOT, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY);
|
|
}
|
|
}
|