2021-12-05 17:54:36 +00:00
|
|
|
#include "NpcNjAssistantServer.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "InventoryComponent.h"
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "MissionComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "Item.h"
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "eMissionState.h"
|
2023-03-04 07:16:37 +00:00
|
|
|
#include "eReplicaComponentType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void NpcNjAssistantServer::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {
|
|
|
|
if (missionID != mailMission) return;
|
|
|
|
|
|
|
|
if (missionState == eMissionState::COMPLETE || missionState == eMissionState::READY_TO_COMPLETE) {
|
|
|
|
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"switch", 0, 0, LWOOBJID_EMPTY, "", target->GetSystemAddress());
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-09 08:27:05 +00:00
|
|
|
auto* inv = target->GetComponent<InventoryComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
// If we are ready to complete our missions, we take the kit from you:
|
|
|
|
if (inv && missionState == eMissionState::READY_TO_COMPLETE) {
|
|
|
|
auto* id = inv->FindItemByLot(14397); //the kit's lot
|
|
|
|
|
|
|
|
if (id != nullptr) {
|
|
|
|
inv->RemoveItem(id->GetLot(), id->GetCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (missionState == eMissionState::AVAILABLE) {
|
2023-06-09 08:27:05 +00:00
|
|
|
auto* missionComponent = target->GetComponent<MissionComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
missionComponent->CompleteMission(mailAchievement, true);
|
|
|
|
}
|
|
|
|
}
|