Skip to content

Commit 522ee9b

Browse files
authored
Merge pull request #113 from How-Bout-No/feature/enhanced-compat
fix(Mm): Proper checks
2 parents 7787c95 + 72a11ae commit 522ee9b

4 files changed

Lines changed: 58 additions & 30 deletions

File tree

SSV2/includes/data/globals_locals.lua

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -907,12 +907,22 @@ return {
907907
capture_group = 1
908908
}
909909
},
910-
submarine_global = {
911-
description = "Submarine Global",
912-
file = "am_mp_submarine.c",
910+
service_vehicles_global = {
911+
description = [[Stores status of Service Vehicles.
912+
To find bitsets:
913+
> freemode.c func_15166
914+
> Global_2733138.f_XXX ;; i.e. 613 for Kosatka, 592 for Acid Lab
915+
> func_15202(blah, blah, blah, THIS_NUMBER_IS_YOUR_BITSET_OFFSET);
916+
917+
Scrolling through offsets for Vectors has revealed that this has the coords of:
918+
- Super Yacht @ offset -48
919+
- Kosatka/Terrorbyte/MOC @ offset +13
920+
- Acid Lab @ offset +75
921+
]],
922+
file = "freemode.c",
913923
LEGACY = {
914924
value = 2658291,
915-
pattern = [[if \(NETWORK::NETWORK_DOES_NETWORK_ID_EXIST\(Global_(\d{7})\[.*?Param0 /\*(\d+)\*/\]\.(f_\d{2})\)\)]],
925+
pattern = [[MISC::SET_BIT\(&\(Global_(\d{7})\[PLAYER::PLAYER_ID\(\) /\*(\d{3})\*/\]\.(f_\d{3})\.f_\d{1}\), 31\);]],
916926
capture_group = 1,
917927
offsets = {
918928
{
@@ -921,14 +931,14 @@ return {
921931
description = "playerID read size."
922932
},
923933
{
924-
value = 52,
934+
value = 325,
925935
capture_group = 3
926936
}
927937
}
928938
},
929939
ENHANCED = {
930940
value = 2658294,
931-
pattern = [[if \(NETWORK::NETWORK_DOES_NETWORK_ID_EXIST\(Global_(\d{7})\[.*?Param0 /\*(\d+)\*/\]\.(f_\d{2})\)\)]],
941+
pattern = [[MISC::SET_BIT\(&\(Global_(\d{7})\[PLAYER::PLAYER_ID\(\) /\*(\d{3})\*/\]\.(f_\d{3})\.f_\d{1}\), 31\);]],
932942
capture_group = 1,
933943
offsets = {
934944
{
@@ -937,7 +947,7 @@ return {
937947
description = "playerID read size."
938948
},
939949
{
940-
value = 52,
950+
value = 325,
941951
capture_group = 3
942952
}
943953
}

SSV2/includes/data/yrv3_data.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ local RawBusinessData <const> = {
531531
{ gxt = "MP_DBASE_2", coords = vec3:new(34.4699, 2620.9768, 84.6202) },
532532
{ gxt = "MP_DBASE_3", coords = vec3:new(2755.9807, 3907.2722, 44.3148) },
533533
{ gxt = "MP_DBASE_4", coords = vec3:new(3389.6028, 5508.971, 24.875) },
534-
{ gxt = "MP_DBASE_6", coords = vec3:new(19.4492, 6825.3613, 14.4952) },
534+
{ gxt = "MP_DBASE_6", coords = vec3:new(19.4492, 6825.3613, 14.4952) }, -- skips DBASE_5
535535
{ gxt = "MP_DBASE_7", coords = vec3:new(-2229.408, 2395.4102, 12.0106) },
536536
{ gxt = "MP_DBASE_8", coords = vec3:new(-3.0095, 3344.4888, 40.2769) },
537537
{ gxt = "MP_DBASE_9", coords = vec3:new(2086.0674, 1761.3461, 103.043) },

SSV2/includes/features/Mastermind.lua

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ local secondary_targets = { "CASH", "WEED", "COKE", "GOLD" }
3131
---@class FieldHangarProperty : GenericProperty
3232
---@class SubmarineProperty : GenericProperty
3333
---@field public heading float
34+
---@field public is_spawned boolean
3435

3536
---@alias HEIST_TYPES table<integer, HeistInfo>
3637

@@ -101,17 +102,34 @@ function Mastermind:GetCayoSecTargets()
101102
return loot_i or -1, loot_c or -1
102103
end
103104

104-
---@return ScriptGlobal
105-
local function GetSubCoordsGlobal()
106-
local coords_global = SGSL:Get(SGSL.data.submarine_global)
107-
local pid_size = coords_global:GetOffset(1)
108-
local offset2 = coords_global:GetOffset(2)
109-
local vec_offset = 286 -- magic
105+
--- Returns the coords and heading to either the Kosatka/Terrorbyte/MOC, whichever is called in.
106+
---@return vec3, float
107+
local function getServiceVehicleCoords()
108+
local ser_veh_global = SGSL:Get(SGSL.data.service_vehicles_global)
109+
local pid_size = ser_veh_global:GetOffset(1)
110+
local offset2 = ser_veh_global:GetOffset(2)
111+
local vec_offset = 13
110112

111-
return coords_global:AsGlobal()
113+
local final = ser_veh_global:AsGlobal()
112114
:At(LocalPlayer:GetPlayerID(), pid_size)
113115
:At(offset2)
114116
:At(vec_offset)
117+
118+
return final:ReadVec3(), final:At(3):ReadFloat()
119+
end
120+
121+
---@return boolean
122+
local function isSubmarineSpawned()
123+
local sub_global = SGSL:Get(SGSL.data.service_vehicles_global)
124+
local pid_size = sub_global:GetOffset(1)
125+
local offset2 = sub_global:GetOffset(2)
126+
local sub_offset = 4
127+
local sub_status = sub_global:AsGlobal()
128+
:At(LocalPlayer:GetPlayerID(), pid_size)
129+
:At(offset2)
130+
:At(sub_offset)
131+
:ReadInt()
132+
return Bit.IsBitSet(sub_status, 31)
115133
end
116134

117135
function Mastermind:ReadPropertyData()
@@ -135,17 +153,17 @@ function Mastermind:ReadPropertyData()
135153
end
136154

137155
local hangar_idx = stats.get_int("MPX_MCKENZIE_HANGAR_OWNED")
138-
if (hangar_idx > 0) then
139-
local hangar_ref = self.m_raw_data.FieldHangar[1]
156+
local hangar_ref = self.m_raw_data.FieldHangar[hangar_idx]
157+
if (hangar_ref) then
140158
self.m_properties.hangar = {
141159
name = Game.GetGXTLabel(hangar_ref.gxt),
142160
coords = hangar_ref.coords
143161
}
144162
end
145163

146164
local facility_idx = stats.get_int("MPX_DBASE_OWNED")
147-
if (facility_idx > 0) then
148-
local facility_ref = self.m_raw_data.Facilities[facility_idx]
165+
local facility_ref = self.m_raw_data.Facilities[facility_idx]
166+
if (facility_ref) then
149167
self.m_properties.facility = {
150168
name = Game.GetGXTLabel(facility_ref.gxt),
151169
coords = facility_ref.coords
@@ -154,11 +172,11 @@ function Mastermind:ReadPropertyData()
154172

155173
local sub_hash = stats.get_int("MPX_IH_SUB_OWNED")
156174
if (sub_hash == _J("kosatka")) then
157-
local global = GetSubCoordsGlobal()
158175
self.m_properties.submarine = {
159176
name = Game.GetGXTLabel("CELL_SUBMARINE"),
160-
coords = global:ReadVec3(),
161-
heading = global:At(3):ReadFloat()
177+
coords = vec3:zero(),
178+
heading = 0.0,
179+
is_spawned = isSubmarineSpawned()
162180
}
163181
end
164182
end)
@@ -230,9 +248,10 @@ function Mastermind:GetSubmarine()
230248
return
231249
end
232250

233-
local sub_global = GetSubCoordsGlobal()
234-
sub.coords = sub_global:ReadVec3()
235-
sub.heading = sub_global:At(3):ReadFloat()
251+
sub.is_spawned = isSubmarineSpawned()
252+
if (sub.is_spawned) then
253+
sub.coords, sub.heading = getServiceVehicleCoords()
254+
end
236255
return sub
237256
end
238257

SSV2/includes/frontend/mastermind_ui.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,9 @@ local function drawCayoTab()
152152
end
153153

154154
local request_kosatka = SGSL:Get(SGSL.data.request_services_global):AsGlobal():At(613)
155-
local sub_requested = request_kosatka:ReadInt() == 1
156-
local sub_spawned = not sub.coords:is_zero()
155+
local sub_requested = request_kosatka:ReadInt() == 1
157156

158-
ImGui.BeginDisabled(not sub_spawned)
157+
ImGui.BeginDisabled(not sub.is_spawned)
159158
if (GUI:Button(_T("GENERIC_TELEPORT"))) then
160159
local forward_angle = math.rad(sub.heading + 90)
161160
local offset = vec3:new(math.cos(forward_angle), math.sin(forward_angle), 4) -- front of door
@@ -170,7 +169,7 @@ local function drawCayoTab()
170169

171170
local btn_label = (sub_requested) and ImGui.TextSpinner() or _T("YH_CAYO_REQUEST_SUB")
172171

173-
ImGui.BeginDisabled(sub_requested or sub_spawned)
172+
ImGui.BeginDisabled(sub_requested or sub.is_spawned)
174173
ImGui.SameLine()
175174
if (GUI:Button(btn_label)) then
176175
ThreadManager:Run(function()
@@ -388,7 +387,7 @@ end
388387

389388
-- Maybe port https://github.com/YimMenu/YimMenuV2/blob/enhanced/src/game/features/recovery/Heist/ApartmentHeist.cpp ?
390389
-- Apartment heists actually seem complicated in that (I assume) since they're old they use a different method of storing progress as there isn't just 1 stat to check like all the others
391-
-- Or if there is, there only *was* because no stats I've found seem to do anything today, like the stat from that link right there. Doesn't do anything, am I missing something?
390+
-- Or if there is, there only *was* because no stats I've found seem to do anything today, like the stat from that link right there. Doesn't do anything here or in YimMenuV2, am I missing something?
392391
local function drawAptTab()
393392
end
394393

0 commit comments

Comments
 (0)