DarkflameServer/dScripts/02_server/Map/njhub/NjScrollChestServer.cpp
Aaron Kimbrell 6aa90ad5b2
Breakout rest of the enums from dCommonVars and clean it up (#1061)
* Breakout rest of the enums from dcommonvars
so we don't have to deal with merge conflicts
ePlayerFlags is not a scoped enum, yet, due to it's complexity

* address feedback

* make player flag types consistent

* fix typo
2023-05-02 17:39:21 -05:00

18 lines
582 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::NONE);
}
}