2021-12-05 17:54:36 +00:00
|
|
|
#include "NsTokenConsoleServer.h"
|
|
|
|
#include "InventoryComponent.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "Character.h"
|
|
|
|
#include "MissionComponent.h"
|
2023-12-29 04:24:30 +00:00
|
|
|
#include "QuickBuildComponent.h"
|
2023-05-02 22:39:21 +00:00
|
|
|
#include "eTerminateType.h"
|
|
|
|
#include "ePlayerFlag.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void NsTokenConsoleServer::OnStartup(Entity* self) {
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NsTokenConsoleServer::OnUse(Entity* self, Entity* user) {
|
2023-12-29 04:24:30 +00:00
|
|
|
auto* quickBuildComponent = self->GetComponent<QuickBuildComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-12-29 04:24:30 +00:00
|
|
|
if (quickBuildComponent == nullptr) {
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-12-29 04:24:30 +00:00
|
|
|
if (quickBuildComponent->GetState() != eQuickBuildState::COMPLETED) {
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
|
|
|
auto* missionComponent = user->GetComponent<MissionComponent>();
|
|
|
|
auto* character = user->GetCharacter();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (inventoryComponent == nullptr || missionComponent == nullptr || character == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (inventoryComponent->GetLotCount(6194) < 25) {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
inventoryComponent->RemoveItem(6194, 25);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
const auto useSound = self->GetVar<std::string>(u"sound1");
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (!useSound.empty()) {
|
2024-04-11 15:29:49 +00:00
|
|
|
GameMessages::SendPlayNDAudioEmitter(self, user->GetSystemAddress(), useSound);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2022-04-24 03:35:34 +00:00
|
|
|
// Player must be in faction to interact with this entity.
|
|
|
|
LOT tokenLOT = 0;
|
2023-05-02 22:39:21 +00:00
|
|
|
if (character->GetPlayerFlag(ePlayerFlag::VENTURE_FACTION)) //venture
|
2022-04-24 03:35:34 +00:00
|
|
|
tokenLOT = 8321;
|
2023-05-02 22:39:21 +00:00
|
|
|
else if (character->GetPlayerFlag(ePlayerFlag::ASSEMBLY_FACTION)) //assembly
|
2022-04-24 03:35:34 +00:00
|
|
|
tokenLOT = 8318;
|
2023-05-02 22:39:21 +00:00
|
|
|
else if (character->GetPlayerFlag(ePlayerFlag::PARADOX_FACTION)) //paradox
|
2022-04-24 03:35:34 +00:00
|
|
|
tokenLOT = 8320;
|
2023-05-02 22:39:21 +00:00
|
|
|
else if (character->GetPlayerFlag(ePlayerFlag::SENTINEL_FACTION)) //sentinel
|
2022-04-24 03:35:34 +00:00
|
|
|
tokenLOT = 8319;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-05-02 22:39:21 +00:00
|
|
|
inventoryComponent->AddItem(tokenLOT, 5, eLootSourceType::NONE);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
missionComponent->ForceProgressTaskType(863, 1, 1, false);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-05-02 22:39:21 +00:00
|
|
|
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|