DarkflameServer/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp

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

62 lines
1.8 KiB
C++
Raw Permalink Normal View History

#include "NsTokenConsoleServer.h"
#include "InventoryComponent.h"
#include "GameMessages.h"
#include "Character.h"
#include "MissionComponent.h"
#include "RebuildComponent.h"
#include "eTerminateType.h"
#include "ePlayerFlag.h"
void NsTokenConsoleServer::OnStartup(Entity* self) {
2022-07-28 13:39:57 +00:00
}
void NsTokenConsoleServer::OnUse(Entity* self, Entity* user) {
auto* rebuildComponent = self->GetComponent<RebuildComponent>();
2022-07-28 13:39:57 +00:00
if (rebuildComponent == nullptr) {
return;
}
2022-07-28 13:39:57 +00:00
if (rebuildComponent->GetState() != eRebuildState::COMPLETED) {
return;
}
2022-07-28 13:39:57 +00:00
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
auto* missionComponent = user->GetComponent<MissionComponent>();
auto* character = user->GetCharacter();
2022-07-28 13:39:57 +00:00
if (inventoryComponent == nullptr || missionComponent == nullptr || character == nullptr) {
return;
}
2022-07-28 13:39:57 +00:00
if (inventoryComponent->GetLotCount(6194) < 25) {
return;
}
2022-07-28 13:39:57 +00:00
inventoryComponent->RemoveItem(6194, 25);
2022-07-28 13:39:57 +00:00
const auto useSound = self->GetVar<std::string>(u"sound1");
2022-07-28 13:39:57 +00:00
if (!useSound.empty()) {
GameMessages::SendPlayNDAudioEmitter(self, UNASSIGNED_SYSTEM_ADDRESS, useSound);
}
2022-07-28 13:39:57 +00:00
// Player must be in faction to interact with this entity.
LOT tokenLOT = 0;
if (character->GetPlayerFlag(ePlayerFlag::VENTURE_FACTION)) //venture
tokenLOT = 8321;
else if (character->GetPlayerFlag(ePlayerFlag::ASSEMBLY_FACTION)) //assembly
tokenLOT = 8318;
else if (character->GetPlayerFlag(ePlayerFlag::PARADOX_FACTION)) //paradox
tokenLOT = 8320;
else if (character->GetPlayerFlag(ePlayerFlag::SENTINEL_FACTION)) //sentinel
tokenLOT = 8319;
2022-07-28 13:39:57 +00:00
inventoryComponent->AddItem(tokenLOT, 5, eLootSourceType::NONE);
2022-07-28 13:39:57 +00:00
missionComponent->ForceProgressTaskType(863, 1, 1, false);
2022-07-28 13:39:57 +00:00
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
}