DarkflameServer/dScripts/NtDukeServer.cpp
David Markowitz 8cdb388915
Optimize scripts for faster compilation (#597)
* Implement Precompiled Headers

* First volume of optimizations

* Scripts A-B

Gonna be doing this in alphabetical order now.

* C Scripts and remove unneeded includes from base cppscripts header

Remove the MissionComponent and Loot includes from all base scripts and place their needed includes in the respective scripts.

* D scripts

* F scripts

* F scripts 2

Finish up removing extraneous includes from scripts that start with the letter F

* G scripts

Removing extraneous includes from scripts that start with the letter G

* I scripts

Removing extraneous includes from scripts that start with the letter I

* M-Z scripts

Removing extraneous includes from scripts that start with the letter M-Z

* Revert "Implement Precompiled Headers"

This reverts commit d79d8d4991.

* Revert "Revert "Implement Precompiled Headers""

This reverts commit 0597faf308.

* Add back in PCH

Add back in PCH

* Fix CMake

Whitespace

Remove duplicate file glob

Remove newline
2022-07-04 23:00:10 -07:00

39 lines
1.6 KiB
C++

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