-
Notifications
You must be signed in to change notification settings - Fork 1
/
Functions.cpp
198 lines (143 loc) · 6.19 KB
/
Functions.cpp
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#include "pch.h"
#include "Functions.h"
#include "Class.h"
#include "GameMode.h"
#include "FortPlayerController.h"
#include "FortGameStateAthena.h"
#include "Match.h"
auto UFunctions::SetTimeOfDay(float Time)
{
GetGame()->FortKismetLibrary.SetTimeOfDay(GGameEngine.GameViewport->World, Time);
}
void UFunctions::TeleportToSpawn()
{
GetGame()->LocalPlayers[0].GetPlayerController()->CheatManager->BugItGo(-156128.36, -159492.78, -2996.30, 0, 0, 0);
PLOGI << "Teleported to spawn island";
}
void UFunctions::TeleportToMain()
{
GetGame()->LocalPlayers[0].GetPlayerController()->CheatManager->BugItGo(0, 0, 0, 0, 0, 0);
}
void UFunctions::TeleportToCoords(float X, float Y, float Z)
{
GetGame()->LocalPlayers[0].GetPlayerController()->CheatManager->BugItGo(X, Y, Z, 0, 0, 0);
}
// ToDo: this is currently not working. Do research
void UFunctions::DestroyAllHLODs()
{
// 1. Wrong cheatmanager?
// 2. Is there a better function?
auto HLODSMActor = UE4::FindObject<InternalUObject*>(XOR(L"Class /Script/FortniteGame.FortHLODSMActor"));
auto HLODSMActorconv = new AActor(HLODSMActor);
GetGame()->LocalPlayers[0].GetPlayerController()->CheatManager->DestroyAll(HLODSMActorconv);
PLOGD << "HLODSM Actor were destroyed.";
}
void UFunctions::Travel(const wchar_t* url)
{
if (url == nullptr) {
PLOGE << "Travel: url is null";
return;
}
PLOGD.printf("Travel: To Url: %ws", std::wstring(url).c_str());
FString fUrl(url);
PLOGI << "Size is: " << GetGame()->LocalPlayers.size();
ULocalPlayer player = GetGame()->LocalPlayers[0];
APlayerController* pContoller = player.GetPlayerController();
pContoller->SwitchLevel(fUrl);
GGameEngine.GameViewport->World->UpdateProps();
}
void UFunctions::StartMatch()
{
auto GameMode = AGameMode(GGameEngine.GameViewport->World->AuthorityGameMode);
GameMode.StartMatch();
PLOGI << "Match started!";
}
//Simulates the server telling the game that it's ready to start match
void UFunctions::ServerReadyToStartMatch()
{
auto playerController = AFortPlayerController(GetGame()->LocalPlayers[0].GetPlayerController());
playerController.ServerReadyToStartMatch();
playerController.ServerSetClientHasFinishedLoading(true);
playerController.SetbHasServerFinishedLoading(true);
playerController.OnRep_bHasServerFinishedLoading();
PLOGI << "Server reported ReadyToStartMatch";
}
void UFunctions::SetPlaylist()
{
auto gameState = AFortGameStateAthena(GGameEngine.GameViewport->World->GetGameState());
if (Util::IsBadReadPtr(gPlaylist))
{
PLOGE << "gPlaylist is nullptr";
}
gameState.CurrentPlaylistInfo->SetBasePlaylist(gPlaylist);
gameState.CurrentPlaylistInfo->SetOverridePlaylist(gPlaylist);
gameState.OnRep_CurrentPlaylistInfo();
PLOGD << "Playlist was set";
}
void UFunctions::SetGamePhase()
{
auto gameState = AFortGameStateAthena(GGameEngine.GameViewport->World->GetGameState());
*gameState.GamePhase = EAthenaGamePhase::None;
gameState.OnRep_GamePhase(EAthenaGamePhase::Setup);
PLOGD << "Game phase was set";
}
/*void UFunctions::LoadAndStreamInLevel(const wchar_t* EventSequenceMap)
{
ObjectFinder EngineFinder = ObjectFinder::EntryPoint(uintptr_t(GEngine));
ObjectFinder GameViewPortClientFinder = EngineFinder.Find(XOR(L"GameViewport"));
ObjectFinder WorldFinder = GameViewPortClientFinder.Find(XOR(L"World"));
//Loading the level instance in memory
auto LoadLevelInstance = UE4::FindObject<UFunction*>(XOR(L"Function /Script/Engine.LevelStreamingDynamic:LoadLevelInstance"));
auto LevelStreamingDynamic = UE4::FindObject<UObject*>(XOR(L"LevelStreamingDynamic /Script/Engine.Default__LevelStreamingDynamic"));
FRotator WorldRotation;
WorldRotation.Yaw = 0;
WorldRotation.Roll = 0;
WorldRotation.Pitch = 0;
ULevelStreamingDynamic_LoadLevelInstance_Params LoadLevelInstanceParams;
LoadLevelInstanceParams.WorldContextObject = WorldFinder.GetObj();
LoadLevelInstanceParams.LevelName = EventSequenceMap;
LoadLevelInstanceParams.Location = FVector(0, 0, 0);
LoadLevelInstanceParams.Rotation = WorldRotation;
ProcessEvent(LevelStreamingDynamic, LoadLevelInstance, &LoadLevelInstanceParams);
ObjectFinder LocalPlayer = EngineFinder.Find(XOR(L"GameInstance")).Find(XOR(L"LocalPlayers"));
ObjectFinder PlayerControllerFinder = LocalPlayer.Find(XOR(L"PlayerController"));
auto KismetSysLib = UE4::FindObject<UObject*>(XOR(L"KismetSystemLibrary /Script/Engine.Default__KismetSystemLibrary"));
auto fn = UE4::FindObject<UFunction*>(XOR(L"Function /Script/Engine.KismetSystemLibrary:ExecuteConsoleCommand"));
std::wstring command = L"streamlevelin " + std::wstring(EventSequenceMap);
UKismetSystemLibrary_ExecuteConsoleCommand_Params params;
params.WorldContextObject = WorldFinder.GetObj();
params.Command = command.c_str();
params.SpecificPlayer = PlayerControllerFinder.GetObj();
ProcessEvent(KismetSysLib, fn, ¶ms);
}
void UFunctions::Play(const wchar_t* AnimationPlayerFullName)
{
auto Play = UE4::FindObject<UFunction*>(XOR(L"Function /Script/MovieScene.MovieSceneSequencePlayer:Play"));
auto Sequence = UE4::FindObject<void*>(AnimationPlayerFullName);
ProcessEvent(Sequence, Play, nullptr);
}*/
void UFunctions::ConsoleLog(std::wstring message)
{
auto gameMode = dynamic_cast<AGameMode*>(GGameEngine.GameViewport->World->AuthorityGameMode);
gameMode->Say(FString(message.c_str()));
}
void UFunctions::DestoryActor(AActor* actor)
{
actor->K2_DestroyActor();
}
/*void UFunctions::PlayCustomPlayPhaseAlert()
{
// ToDo: this shit is not working
return;
auto AGPCW = UE4::FindObject<UObject*>(XOR(L"AthenaGamePhaseChangeWidget_C /Engine/Transient.FortEngine_"));
auto AGPCWFinder = ObjectFinder::EntryPoint(uintptr_t(AGPCW));
// this things causes an error because UE4::FindObject<UObject *>() line 199 -> UE4::GetObjectFullName() line 135 fails and crashes the game
auto PlayIntroAnim = UE4::FindObject<UObject*>(XOR(L"Function /Game/Athena/HUD/Phase/AthenaGamePhaseChangeWidget.AthenaGamePhaseChangeWidget_C:PlayIntroAnimation"));
PlayIntroAnim_Params PlayIntroAnimParams;
PlayIntroAnimParams.Step = EAthenaGamePhaseStep::Count;
ProcessEvent(AGPCW, PlayIntroAnim, &PlayIntroAnimParams);
}*/
UObject* UFunctions::StaticLoadObjectEasy(UClass* inClass, const wchar_t* inName, UObject* inOuter)
{
return StaticLoadObject(inClass, inOuter, inName, nullptr, 0, nullptr, false, nullptr);
}