-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathQuestDebugView.cpp
More file actions
92 lines (70 loc) · 2.72 KB
/
Copy pathQuestDebugView.cpp
File metadata and controls
92 lines (70 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <Services/DebugService.h>
#include <Services/QuestService.h>
#include <Services/PapyrusService.h>
#include <PlayerCharacter.h>
#include <Forms/TESQuest.h>
#include <Forms/TESObjectCELL.h>
#include <Events/MoveActorEvent.h>
#include <imgui.h>
void DebugService::DrawQuestDebugView()
{
auto* pPlayer = PlayerCharacter::Get();
if (!pPlayer) return;
ImGui::Begin("Quest log");
Set<uint32_t> foundQuests{};
for (auto &objective : pPlayer->objectives)
{
TESQuest* pQuest = objective.instance->quest;
if (!pQuest)
continue;
if (QuestService::IsNonSyncableQuest(pQuest))
continue;
if (foundQuests.contains(pQuest->formID))
continue;
foundQuests.insert(pQuest->formID);
if (!pQuest->IsActive())
continue;
char questName[256];
sprintf_s(questName, std::size(questName), "%s (%s)", pQuest->fullName.value.AsAscii(), pQuest->idName.AsAscii());
if (!ImGui::CollapsingHeader(questName))
continue;
if (ImGui::CollapsingHeader("Stages"))
{
for (auto* pStage : pQuest->stages)
{
ImGui::TextColored({0.f, 255.f, 255.f, 255.f}, "Stage: %d, is done? %s", pStage->stageIndex, pStage->IsDone() ? "true" : "false");
char setStage[64];
sprintf_s(setStage, std::size(setStage), "Set stage (%d)", pStage->stageIndex);
if (ImGui::Button(setStage))
pQuest->ScriptSetStage(pStage->stageIndex);
}
}
if (ImGui::CollapsingHeader("Actors"))
{
Set<uint32_t> foundActors{};
for (BGSScene* pScene : pQuest->scenes)
{
for (uint32_t actorId : pScene->actorIds)
{
Actor* pActor = Cast<Actor>(pQuest->GetAliasedRef(actorId));
if (!pActor)
continue;
if (foundActors.contains(pActor->formID))
continue;
foundActors.insert(pActor->formID);
char name[256];
sprintf_s(name, std::size(name), "%s (%x)", pActor->baseForm->GetName(), pActor->formID);
ImGui::BulletText(name);
ImGui::PushID(pActor->formID);
if (ImGui::Button("Teleport to me"))
{
auto* pPlayer = PlayerCharacter::Get();
m_world.GetRunner().Trigger(MoveActorEvent(pActor->formID, pPlayer->parentCell->formID, pPlayer->position));
}
ImGui::PopID();
}
}
}
}
ImGui::End();
}