-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathSoloMissions.lua
More file actions
360 lines (290 loc) · 12.3 KB
/
SoloMissions.lua
File metadata and controls
360 lines (290 loc) · 12.3 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
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
local SOLO_MISSIONS <const> = gui.add_tab("Solo Missions")
function locals.set_bits(scriptName, index, ...)
local value = locals.get_int(scriptName, index)
for _, bit in ipairs({ ... }) do
value = value | (1 << bit)
end
locals.set_int(scriptName, index, value)
end
local function IsOnline()
return network.is_session_started() and not script.is_active("maintransition")
end
local function GetMissionScript()
if script.is_active("fm_mission_controller") then
return "fm_mission_controller"
end
if script.is_active("fm_mission_controller_2020") then
return "fm_mission_controller_2020"
end
return nil
end
local FMMC_LAUNCHER <const> = "fmmc_launcher"
local FREEMODE <const> = "freemode"
----------------------------------------
-- VARIABLES
----------------------------------------
local TARGET_VERSION <const> = "1.72-3725"
-- search in fmmc_launcher.c
local scrGlobals = {
minNumParticipants = 4718592 + 3536, -- regex: Global_\d+\.f_\d+\s?=.+?"minNu"
numberOfTeams = 4718592 + 3539, -- regex: Global_\d+\.f_\d+\s?=.+?"dtn"
maxNumberOfTeams = 4718592 + 3540, -- regex: Global_\d+\.f_\d+\s?=.+?"tnum"
numPlayersPerTeam = 4718592 + 3542, -- regex: else\s+?{\s+?HUD::ADD_TEXT_COMPONENT_INTEGER\(Global_
nextContentID = 4718592 + 132821, -- regex: "nrcid"[^{}]+?Global_\d+\.f_\d+\[
criticalMinimumForTeam = 4718592 + 185951, -- regex: "tcmin"[^}]+?Global_\d+\.f_\d+\[
}
local function MissionHeaderMinPlayers(index)
return 794954 + 4 + 1 + index * 95 + 75 -- regex: -1279529723;[\s\S]+?Global_.+= 1;
end
local scrLocals = {
["fmmc_launcher"] = {
minPlayers = 20054 + 15, -- regex: Local_\d+\.f_\d+ = 1;\s+Global_\d+\.f_\d+ = 1;
missionVariation = 20054 + 34, -- regex: HUD_MG_TENNIS.+\s+.+?Local_\d+\.f_\d+ \+ 1
},
["fm_mission_controller"] = {
serverBitSet = 19791 + 1,
serverBitSet2 = 19791 + 2,
nextMission = 19791 + 1062, -- regex: (Local_\d+\.f_\d+) < 6 && \1 >= 0
teamScore = 19791 + 1232 + 1, -- regex: < 4\)\s+?{\s+?(Local_\d+\.f_\d+\[.+?\]) = \(?\1 \+ .+?\)?;\s+if
},
["fm_mission_controller_2020"] = {
serverBitSet = 55789 + 1,
serverBitSet2 = 55789 + 2,
nextMission = 55789 + 1589, -- regex: same as above
teamScore = 55789 + 1776 + 1, -- regex: same as above
}
}
----------------------------------------
-- SOLO MISSION
----------------------------------------
local soloEnabled = false
local casinoHeistPatchEnabled = false
local casinoHeistPatch = nil
SOLO_MISSIONS:add_imgui(function()
if not IsOnline() then
ImGui.Text("Unavailable in Single Player.")
return
end
ImGui.Text("Compatible Game Version: " .. TARGET_VERSION)
ImGui.Text("Please check your game version before using!")
ImGui.Dummy(1, 10)
ImGui.SeparatorText("Solo Missions")
ImGui.Spacing()
soloEnabled, _ = ImGui.Checkbox("Enable Solo Missions", soloEnabled)
ImGui.Spacing()
if ImGui.Button("Skip to Next Checkpoint") then
local mscript = GetMissionScript()
if not mscript then return end
locals.set_bits(mscript, scrLocals[mscript].serverBitSet2, 17)
end
if ImGui.Button("Instant Finish") then
local mscript = GetMissionScript()
if not mscript then return end
for i = 0, 5 do
globals.set_string(scrGlobals.nextContentID + 1 + i * 6, "", 0)
end
locals.set_int(mscript, scrLocals[mscript].nextMission, 5)
locals.set_int(mscript, scrLocals[mscript].teamScore, 999999)
locals.set_bits(mscript, scrLocals[mscript].serverBitSet, 9, 16)
end
ImGui.SameLine()
if ImGui.Button("Force Fail") then
local mscript = GetMissionScript()
if not mscript then return end
locals.set_bits(mscript, scrLocals[mscript].serverBitSet, 16, 20)
end
ImGui.Dummy(1, 10)
ImGui.SeparatorText("Casino Heist Patch")
ImGui.Spacing()
casinoHeistPatchEnabled, Clicked = ImGui.Checkbox("Enable Patch", casinoHeistPatchEnabled)
if Clicked then
script.run_in_fiber(function()
if casinoHeistPatchEnabled then
if casinoHeistPatch then
casinoHeistPatch:enable_patch()
return
end
casinoHeistPatch = scr_patch:new(
FMMC_LAUNCHER,
"SCJJAT",
"2D 01 03 00 00 5D ? ? ? 2A 06 56 05 00 5D ? ? ? 20 2A 06 56 05 00 5D",
5,
{ 0x71, 0x2E, 0x01, 0x01 }
)
else
if casinoHeistPatch then
casinoHeistPatch:disable_patch()
end
end
end)
end
ImGui.Dummy(1, 10)
ImGui.BulletText("Allows you to set up the final planning board.")
ImGui.BulletText("Make sure it's enabled before launching the heist\nand disabled after completing the heist.")
ImGui.BulletText("It is not recommended to keep it enabled continuously.")
end)
----------------------------------------
-- MISSION LAUNCHER
----------------------------------------
local MISSION_LAUNCHER <const> = SOLO_MISSIONS:add_tab(" > Mission Launcher")
local fmMissionId = 0
local fmVariation = 0
local fmSubVariation = 0
local missionId = ""
local skipPrepPatchEnabled = false
local skipPrepPatch = nil
MISSION_LAUNCHER:add_imgui(function()
if not IsOnline() then
ImGui.Text("Unavailable in Single Player.")
return
end
ImGui.TextColored(0.9, 0, 0, 1, "WARNING!")
ImGui.TextColored(0.9, 0, 0, 1, "These are advanced features and might not work well.\nIncorrect use may cause game script errors or even game crashes!")
--------------------------------
-- LAUNCH FREEMODE MISSION
--------------------------------
ImGui.Spacing()
ImGui.SeparatorText("Launch Freemode Mission")
ImGui.Spacing()
fmMissionId, _ = ImGui.InputInt("Freemode Mission ID", fmMissionId, 1)
fmVariation, _ = ImGui.InputInt("Freemode Mission Variation", fmVariation, 1)
fmSubVariation, _ = ImGui.InputInt("Freemode Mission Sub-Variation", fmSubVariation, 1)
if ImGui.Button("Check Mission Name") then
script.run_in_fiber(function()
if fmMissionId < -1 or fmVariation < -1 or fmSubVariation < -1 then return end
if NETWORK.NETWORK_IS_ACTIVITY_SESSION() then return end
local name = scr_function.call_script_function(FREEMODE, "get_freemode_mission_name",
"2D 03 06 00 00 38 00 65 ? 96 00 00 00 ? ? 1A 00 00 00", "string", {
{ "int", fmMissionId },
{ "int", fmVariation },
{ "int", fmSubVariation }
})
if not name or name == "" then
name = "Invalid mission"
end
gui.show_message("Check Mission Name", tostring(name))
end)
end
ImGui.SameLine()
ImGui.Text("Check if the mission is valid")
if ImGui.Button("Launch Freemode Mission") then
script.run_in_fiber(function()
if fmMissionId < -1 or fmVariation < -1 or fmSubVariation < -1 then return end
if NETWORK.NETWORK_IS_ACTIVITY_SESSION() then return end
scr_function.call_script_function(FREEMODE, "request_launch_gb_mission",
"2D 03 05 00 00 38 01 70 58", "void", {
{ "int", fmMissionId },
{ "int", fmVariation },
{ "int", fmSubVariation }
})
end)
end
ImGui.SameLine()
if ImGui.Button("Clear Freemode Mission") then
script.run_in_fiber(function()
if NETWORK.NETWORK_IS_ACTIVITY_SESSION() then return end
scr_function.call_script_function(FREEMODE, "clear_gb_mission",
"2D 02 04 00 00 38 00 38 01 5D ? ? ? 2C 01 ? ? 5D ? ? ? 56", "void", {
{ "bool", true },
{ "bool", false }
})
end)
end
ImGui.Spacing()
ImGui.BulletText("Most missions require you to be a boss to launch.")
ImGui.BulletText("Some missions require you to own the corresponding property to launch.")
ImGui.BulletText("If you fail to launch try clearing mission to reset.")
--------------------------------
-- LAUNCH MISSION
--------------------------------
ImGui.Dummy(1, 10)
ImGui.SeparatorText("Launch Mission")
ImGui.Spacing()
missionId, _ = ImGui.InputText("Mission ID/Hash", missionId, 64)
ImGui.SameLine()
if ImGui.Button("Paste") then
missionId = ImGui.GetClipboardText()
end
if ImGui.Button("Launch Mission") then
script.run_in_fiber(function()
if missionId == "" then return end
local missionHash = tonumber(missionId)
if not missionHash then
missionHash = joaat(missionId)
end
if not script.is_active(FMMC_LAUNCHER) then return end
if NETWORK.NETWORK_IS_ACTIVITY_SESSION() then return end
local index = MISC.GET_CONTENT_ID_INDEX(missionHash)
if index == -1 then return end
stats.set_packed_stat_bool(17, true) -- close matchmaking
scr_function.call_script_function(FMMC_LAUNCHER, "launch_v2_corona",
"2D 09 19 00 00 38 01", "void", {
{ "int", -1 }, -- iSeries
{ "int", index }, -- iArrayPos
{ "bool", false }, -- bOnCall
{ "int", -1 }, -- iPlaylistType
{ "bool", false }, -- bSkipSkyCam
{ "bool", false }, -- bSetExitVector
{ "bool", false }, -- bFromWall
{ "bool", true }, -- bSetSkipWarning
{ "int", -1 } -- iForceJobEntryType
})
end)
end
ImGui.SameLine()
skipPrepPatchEnabled, Clicked2 = ImGui.Checkbox("Skip Prep Check", skipPrepPatchEnabled)
if ImGui.IsItemHovered() then
ImGui.SetTooltip("So you can launch some missions without completing the preps.")
end
if Clicked2 then
script.run_in_fiber(function()
if skipPrepPatchEnabled then
if skipPrepPatch then
skipPrepPatch:enable_patch()
return
end
skipPrepPatch = scr_patch:new(
FMMC_LAUNCHER,
"SPMPC",
"2D 01 05 00 00 62 ? ? ? 56 03 00 2E 01 00 5D",
5,
{ 0x2E, 0x01, 0x00 }
)
else
if skipPrepPatch then
skipPrepPatch:disable_patch()
end
end
end)
end
ImGui.Spacing()
ImGui.BulletText("Some jobs require you to be a boss and own the corresponding property.")
ImGui.BulletText("Unstable! You might get kicked, or the game could even crash.")
end)
----------------------------------------
-- LOOP
----------------------------------------
script.register_looped("SOLO_MISSIONS", function()
if soloEnabled then
if script.is_active(FMMC_LAUNCHER) then
local index = locals.get_int(FMMC_LAUNCHER, scrLocals[FMMC_LAUNCHER].missionVariation)
if index > 0 then
locals.set_int(FMMC_LAUNCHER, scrLocals[FMMC_LAUNCHER].minPlayers, 1)
globals.set_int(MissionHeaderMinPlayers(index), 1)
end
end
globals.set_int(scrGlobals.minNumParticipants, 1)
globals.set_int(scrGlobals.numPlayersPerTeam + 1, 1)
globals.set_int(scrGlobals.criticalMinimumForTeam + 1, 0)
globals.set_int(scrGlobals.numberOfTeams, 1)
globals.set_int(scrGlobals.maxNumberOfTeams, 1)
end
end)
event.register_handler(menu_event.ScriptsReloaded, function()
if casinoHeistPatch then
casinoHeistPatch:disable_patch()
end
if skipPrepPatch then
skipPrepPatch:disable_patch()
end
end)