DarkflameServer/dScripts/NtDukeServer.cpp

39 lines
1.5 KiB
C++
Raw Normal View History

#include "NtDukeServer.h"
#include "InventoryComponent.h"
#include "MissionComponent.h"
2022-07-28 13:39:57 +00:00
void NtDukeServer::SetVariables(Entity* self) {
self->SetVar<float_t>(m_SpyProximityVariable, 35.0f);
2022-07-28 13:39:57 +00:00
self->SetVar<SpyData>(m_SpyDataVariable, {
NT_FACTION_SPY_DUKE, 13548, 1319
});
2022-07-28 13:39:57 +00:00
self->SetVar<std::vector<SpyDialogue>>(m_SpyDialogueTableVariable, {
{ "DUKE_NT_CONVO_1", 0 },
{ "DUKE_NT_CONVO_2", 0 },
{ "DUKE_NT_CONVO_3", 0 },
});
2022-07-28 13:39:57 +00:00
// If there's an alternating conversation, indices should be provided using the conversationID variables
self->SetVar<std::vector<LWOOBJID>>(m_SpyCinematicObjectsVariable, { self->GetObjectID() });
}
2022-07-28 13:39:57 +00:00
void NtDukeServer::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, MissionState missionState) {
2022-07-28 13:39:57 +00:00
// Handles adding and removing the sword for the Crux Prime Sword mission
auto* missionComponent = target->GetComponent<MissionComponent>();
auto* inventoryComponent = target->GetComponent<InventoryComponent>();
2022-07-28 13:39:57 +00:00
if (missionComponent != nullptr && inventoryComponent != nullptr) {
auto state = missionComponent->GetMissionState(m_SwordMissionID);
auto lotCount = inventoryComponent->GetLotCount(m_SwordLot);
2022-07-28 13:39:57 +00:00
if ((state == MissionState::MISSION_STATE_AVAILABLE || state == MissionState::MISSION_STATE_ACTIVE) && lotCount < 1) {
inventoryComponent->AddItem(m_SwordLot, 1, eLootSourceType::LOOT_SOURCE_NONE);
} else if (state == MissionState::MISSION_STATE_READY_TO_COMPLETE) {
inventoryComponent->RemoveItem(m_SwordLot, lotCount);
}
}
}