2022-05-10 04:21:20 +00:00
|
|
|
#include "AmTeapotServer.h"
|
|
|
|
#include "InventoryComponent.h"
|
|
|
|
#include "GameMessages.h"
|
2023-01-17 12:07:34 +00:00
|
|
|
#include "Item.h"
|
2023-05-02 22:39:21 +00:00
|
|
|
#include "eTerminateType.h"
|
2022-05-10 04:21:20 +00:00
|
|
|
|
|
|
|
void AmTeapotServer::OnUse(Entity* self, Entity* user) {
|
|
|
|
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
|
|
|
if (!inventoryComponent) return;
|
|
|
|
|
2023-01-17 12:07:34 +00:00
|
|
|
auto* blueFlowerItem = inventoryComponent->FindItemByLot(BLUE_FLOWER_LEAVES, eInventoryType::ITEMS);
|
|
|
|
if (!blueFlowerItem) {
|
|
|
|
blueFlowerItem = inventoryComponent->FindItemByLot(BLUE_FLOWER_LEAVES, eInventoryType::VAULT_ITEMS);
|
|
|
|
if (!blueFlowerItem) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The client allows you to use the teapot only if you have a stack of 10 leaves in some inventory somewhere.
|
|
|
|
if (blueFlowerItem->GetCount() >= 10) {
|
|
|
|
blueFlowerItem->SetCount(blueFlowerItem->GetCount() - 10);
|
2022-05-10 04:21:20 +00:00
|
|
|
inventoryComponent->AddItem(WU_S_IMAGINATION_TEA, 1);
|
|
|
|
}
|
2023-05-02 22:39:21 +00:00
|
|
|
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
|
2022-05-10 04:21:20 +00:00
|
|
|
}
|