2021-12-05 17:54:36 +00:00
|
|
|
#include "NsTokenConsoleServer.h"
|
|
|
|
#include "InventoryComponent.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "Character.h"
|
|
|
|
#include "MissionComponent.h"
|
|
|
|
#include "RebuildComponent.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) {
|
|
|
|
auto* rebuildComponent = self->GetComponent<RebuildComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (rebuildComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-05-02 22:39:21 +00:00
|
|
|
if (rebuildComponent->GetState() != eRebuildState::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()) {
|
|
|
|
GameMessages::SendPlayNDAudioEmitter(self, UNASSIGNED_SYSTEM_ADDRESS, useSound);
|
|
|
|
}
|
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
|
|
|
}
|