DarkflameServer/dScripts/02_server/Map/njhub/NjScrollChestServer.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
581 B
C++
Raw Normal View History

#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");
2023-06-07 07:23:50 +00:00
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::NONE);
}
}