Skip to content

Commit 7989775

Browse files
authored
Merge pull request YimMenu-Lua#109 from How-Bout-No/feature/enhanced-compat
feat(YHV1): Add Doomsday tab and improve Cayo
2 parents f51503b + 8880204 commit 7989775

13 files changed

Lines changed: 393 additions & 164 deletions

File tree

SSV2/includes/data/config.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ local Config <const> = {
282282
dre_cd = false,
283283
ogfa_cd = false,
284284
cayo_cd = false,
285+
dday_cd = false,
285286
},
286287
yrv3 = {
287288
autofill_delay = 500,

SSV2/includes/data/globals_locals.lua

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -894,17 +894,53 @@ return {
894894
}
895895
},
896896
request_services_global = {
897-
description = "Request Services Global.",
898-
file = "am_prostitute.c", -- definitely the right file to use I'm sure of it
897+
description = "Request Services Global. Only used for Kosatka atm, same global for all services.",
898+
file = "am_mp_submarine.c",
899899
LEGACY = {
900900
value = 2733002,
901-
pattern = [[Global_(\d{7})\.f_4 = 0;]],
901+
pattern = [[return Global_(\d{7})\.f_371;]],
902902
capture_group = 1
903903
},
904904
ENHANCED = {
905905
value = 2733138,
906-
pattern = [[Global_(\d{7})\.f_4 = 0;]],
906+
pattern = [[return Global_(\d{7})\.f_371;]],
907907
capture_group = 1
908908
}
909+
},
910+
submarine_global = {
911+
description = "Submarine Global",
912+
file = "am_mp_submarine.c",
913+
LEGACY = {
914+
value = 2658291,
915+
pattern = [[if \(NETWORK::NETWORK_DOES_NETWORK_ID_EXIST\(Global_(\d{7})\[.*?Param0 /\*(\d+)\*/\]\.(f_\d{2})\)\)]],
916+
capture_group = 1,
917+
offsets = {
918+
{
919+
value = 468,
920+
capture_group = 2,
921+
description = "playerID read size."
922+
},
923+
{
924+
value = 52,
925+
capture_group = 3
926+
}
927+
}
928+
},
929+
ENHANCED = {
930+
value = 2658294,
931+
pattern = [[if \(NETWORK::NETWORK_DOES_NETWORK_ID_EXIST\(Global_(\d{7})\[.*?Param0 /\*(\d+)\*/\]\.(f_\d{2})\)\)]],
932+
capture_group = 1,
933+
offsets = {
934+
{
935+
value = 468,
936+
capture_group = 2,
937+
description = "playerID read size."
938+
},
939+
{
940+
value = 52,
941+
capture_group = 3
942+
}
943+
}
944+
}
909945
}
910946
}

SSV2/includes/data/yrv3_data.lua

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,17 @@ local RawBusinessData <const> = {
315315
end
316316
end
317317
},
318+
["dday_cd"] = {
319+
dirty = false,
320+
gstate = function()
321+
return GVars.features.yim_heists.dday_cd
322+
end,
323+
onEnable = function()
324+
if (stats.get_int("MPX_GANGOPS_LAUNCH_TIME") > 0) then
325+
stats.set_int("MPX_GANGOPS_LAUNCH_TIME", 0)
326+
end
327+
end
328+
},
318329
},
319330
SellScripts = {
320331
["gb_smuggler"] = { -- air
@@ -515,17 +526,28 @@ local RawBusinessData <const> = {
515526
[30] = { coords = vec3:new(-3030.341797, 3334.570068, 10.105902) },
516527
[31] = { coords = vec3:new(-3156.140625, 1376.710693, 17.073570) },
517528
},
529+
Facilities = {
530+
{ gxt = "MP_DBASE_1", coords = vec3:new(1273.1376, 2835.0068, 48.0734) }, -- freemode.c func_7238
531+
{ gxt = "MP_DBASE_2", coords = vec3:new(34.4699, 2620.9768, 84.6202) },
532+
{ gxt = "MP_DBASE_3", coords = vec3:new(2755.9807, 3907.2722, 44.3148) },
533+
{ 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) },
535+
{ gxt = "MP_DBASE_7", coords = vec3:new(-2229.408, 2395.4102, 12.0106) },
536+
{ gxt = "MP_DBASE_8", coords = vec3:new(-3.0095, 3344.4888, 40.2769) },
537+
{ gxt = "MP_DBASE_9", coords = vec3:new(2086.0674, 1761.3461, 103.043) },
538+
{ gxt = "MP_DBASE_10", coords = vec3:new(1864.8027, 269.0474, 163.0169) },
539+
},
518540
Nightclubs = {
519-
{ name = "", coords = vec3:new(757.009, -1332.32, 26.1802) }, -- am_mp_nightclub.c func_5118 // case 102: *uParam5 is main entrance corona coords
520-
{ name = "", coords = vec3:new(345.7519, -978.8848, 28.2681) },
521-
{ name = "", coords = vec3:new(-120.906, -1260.49, 28.2088) },
522-
{ name = "", coords = vec3:new(5.53709, 221.35, 106.6566) },
523-
{ name = "", coords = vec3:new(871.47, -2099.57, 29.3768) },
524-
{ name = "", coords = vec3:new(-675.225, -2459.15, 12.8444) },
525-
{ name = "", coords = vec3:new(195.534, -3168.88, 4.7903) },
526-
{ name = "", coords = vec3:new(373.05, 252.13, 101.9097) },
527-
{ name = "", coords = vec3:new(-1283.38, -649.916, 25.5198) },
528-
{ name = "", coords = vec3:new(-1174.85, -1152.3, 4.56128) },
541+
{ coords = vec3:new(757.009, -1332.32, 26.1802) }, -- am_mp_nightclub.c func_5118 // case 102: *uParam5 is main entrance corona coords
542+
{ coords = vec3:new(345.7519, -978.8848, 28.2681) },
543+
{ coords = vec3:new(-120.906, -1260.49, 28.2088) },
544+
{ coords = vec3:new(5.53709, 221.35, 106.6566) },
545+
{ coords = vec3:new(871.47, -2099.57, 29.3768) },
546+
{ coords = vec3:new(-675.225, -2459.15, 12.8444) },
547+
{ coords = vec3:new(195.534, -3168.88, 4.7903) },
548+
{ coords = vec3:new(373.05, 252.13, 101.9097) },
549+
{ coords = vec3:new(-1283.38, -649.916, 25.5198) },
550+
{ coords = vec3:new(-1174.85, -1152.3, 4.56128) },
529551
},
530552
---@alias BusinessHubs array<{ name: string, vpu_tunable: string, max_units_tunable: string, prod_time_tunable: string }>
531553
BusinessHubs = {
@@ -608,7 +630,7 @@ local RawBusinessData <const> = {
608630
{ gxt = "HD_GARNAME", coords = vec3:new(719.3386, -983.1850, 24.1402) },
609631
},
610632
FieldHangar = {
611-
{ gxt = "FHAN_NME_1", coords = vec3:new(2150.65, 4796.60, 41.17) },
633+
{ gxt = "FHAN_NME_1", coords = vec3:new(2152.74, 4791.05, 41.17) },
612634
},
613635
CashSafes = {
614636
regular = {
Lines changed: 99 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
-- * Provide a copy of or a link to the original license (GPL-3.0 or later); see LICENSE.md or <https://www.gnu.org/licenses/>.
88

99

10+
local SGSL = require("includes.services.SGSL")
11+
local secondary_targets = { "CASH", "WEED", "COKE", "GOLD" }
12+
1013
---@class HeistStat
1114
---@field public name string
1215
---@field public val integer
@@ -24,28 +27,29 @@
2427
---@field public coords vec3
2528

2629
---@class AgencyProperty : GenericProperty
30+
---@class FacilityProperty : GenericProperty
2731
---@class FieldHangarProperty : GenericProperty
2832
---@class SubmarineProperty : GenericProperty
33+
---@field public heading float
2934

3035
---@alias HEIST_TYPES table<integer, HeistInfo>
3136

32-
---@class YimHeists
37+
---@class Mastermind
3338
---@field private m_raw_data RawBusinessData
34-
---@field private m_properties { agency: AgencyProperty, hangar: FieldHangarProperty, submarine: SubmarineProperty }
39+
---@field private m_properties { agency: AgencyProperty, hangar: FieldHangarProperty, facility: FacilityProperty, submarine: SubmarineProperty }
3540
---@field m_tab Tab
36-
local YimHeists = { m_raw_data = require("includes.data.yrv3_data") }
37-
YimHeists.__index = YimHeists
41+
local Mastermind = { m_raw_data = require("includes.data.yrv3_data") }
42+
Mastermind.__index = Mastermind
43+
Mastermind.__label = "Mastermind"
3844

39-
---@return YimHeists
40-
function YimHeists:init()
45+
---@return Mastermind
46+
function Mastermind:init()
4147
local instance = setmetatable({
4248
m_properties = {}
4349
}, self)
4450

4551
if (Game.IsOnline()) then
46-
ThreadManager:Run(function()
47-
instance:ReadPropertyData()
48-
end)
52+
instance:ReadPropertyData()
4953
end
5054

5155
Backend:RegisterEventCallback(Enums.eBackendEvent.SESSION_SWITCH, function()
@@ -58,53 +62,61 @@ end
5862
---@param statName string
5963
---@param statVal integer
6064
---@param notifTitle string
61-
function YimHeists:SkipPrep(statName, statVal, notifTitle)
65+
function Mastermind:SkipPrep(statName, statVal, notifTitle)
6266
stats.set_int(statName, statVal)
6367
Notifier:ShowSuccess(notifTitle, _T("YH_PREP_SKIP_NOTIF"))
6468
end
6569

66-
-- https://www.unknowncheats.me/forum/4489469-post16.html EXCEPT setting values as that's greater risk
67-
---@param type string I or C
70+
-- https://www.unknowncheats.me/forum/4489469-post16.html
71+
---@param type string
6872
---@param index integer
69-
function YimHeists:SetSecondaryTargets(type, index)
70-
local secondary_targets = { "CASH", "WEED", "COKE", "GOLD" }
73+
function Mastermind:SetCayoSecTargets(type, index)
7174
local targets = { 0, 0, 0, 0 }
7275
targets[index] = -1
7376

74-
for st = 1, #secondary_targets do
77+
for st = 1, 4 do
7578
local stat_name = _F("MPX_H4LOOT_%s_%s", secondary_targets[st], type)
7679
stats.set_int(stat_name, targets[st])
77-
stats.set_int(stat_name .. "_SCOPED", targets[st])
80+
stats.set_int(_F("%s_SCOPED", stat_name), targets[st])
7881
end
7982

8083
stats.set_int("MPX_H4LOOT_PAINT", -1) -- Not really any reason to have an option for paintings
8184
stats.set_int("MPX_H4LOOT_PAINT_SCOPED", -1)
8285
end
8386

8487
---@return integer, integer
85-
function YimHeists:GetSecondaryTargets()
86-
local secondary_targets = { "CASH", "WEED", "COKE", "GOLD" }
87-
local return_i
88-
local return_c
88+
function Mastermind:GetCayoSecTargets()
89+
local loot_i, loot_c
8990

90-
for st = 1, #secondary_targets do
91+
for st = 1, 4 do
9192
local stat_name = _F("MPX_H4LOOT_%s", secondary_targets[st])
92-
if (stats.get_int(stat_name .. "_I") == -1) then
93-
return_i = st - 1 -- ImGui indexes by 0
93+
if (stats.get_int(_F("%s_I", stat_name)) == -1) then
94+
loot_i = st - 1 -- ImGui indexes by 0
9495
end
95-
if (stats.get_int(stat_name .. "_C") == -1) then
96-
return_c = st - 1
96+
if (stats.get_int(_F("%s_C", stat_name)) == -1) then
97+
loot_c = st - 1
9798
end
9899
end
99100

100-
return return_i or -1, return_c or -1
101+
return loot_i or -1, loot_c or -1
102+
end
103+
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
110+
111+
return coords_global:AsGlobal()
112+
:At(LocalPlayer:GetPlayerID(), pid_size)
113+
:At(offset2)
114+
:At(vec_offset)
101115
end
102116

103-
function YimHeists:ReadPropertyData()
117+
function Mastermind:ReadPropertyData()
104118
ThreadManager:Run(function()
105-
-- a better approach to this would be to read transition state.
106-
-- I forgot how to do that so this will do.
107-
while (script.is_active("maintransition")) do
119+
while (Game.IsInTransition()) do
108120
yield()
109121
end
110122

@@ -123,35 +135,56 @@ function YimHeists:ReadPropertyData()
123135
end
124136

125137
local hangar_idx = stats.get_int("MPX_MCKENZIE_HANGAR_OWNED")
126-
if (YRV3:IsPropertyIndexValid(hangar_idx)) then
138+
if (hangar_idx > 0) then
127139
local hangar_ref = self.m_raw_data.FieldHangar[1]
128140
self.m_properties.hangar = {
129141
name = Game.GetGXTLabel(hangar_ref.gxt),
130142
coords = hangar_ref.coords
131143
}
132144
end
133145

146+
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]
149+
self.m_properties.facility = {
150+
name = Game.GetGXTLabel(facility_ref.gxt),
151+
coords = facility_ref.coords
152+
}
153+
end
154+
134155
local sub_hash = stats.get_int("MPX_IH_SUB_OWNED")
135156
if (sub_hash == _J("kosatka")) then
157+
local global = GetSubCoordsGlobal()
136158
self.m_properties.submarine = {
137-
name = Game.GetGXTLabel("CELL_SUBMARINE"),
138-
-- TODO: I have no idea how to properly get the location of player Kosatka
139-
--
140-
-- It's an index in some global which also has offsets to show if its currently requested or not
141-
-- I attempted to do the same for the acid lab truck but quickly got irritated
142-
coords = Game.Ensure3DCoords(760) or vec3:zero()
159+
name = Game.GetGXTLabel("CELL_SUBMARINE"),
160+
coords = global:ReadVec3(),
161+
heading = global:At(3):ReadFloat()
143162
}
144163
end
145164
end)
146165
end
147166

167+
---@return vec3
168+
function Mastermind:GetAviLocation()
169+
local stat = stats.get_int("MPX_M25_AVI_MISSION_CURRENT")
170+
local blip = HUD.GET_FIRST_BLIP_INFO_ID(76)
171+
if (blip and stat ~= 4) then
172+
local blip_coords = HUD.GET_BLIP_INFO_ID_COORD(blip)
173+
local forward_angle = math.rad(HUD.GET_BLIP_ROTATION(blip) + 90)
174+
local offset = vec3:new(math.cos(forward_angle), math.sin(forward_angle), 0) -- front of payphone
175+
return blip_coords + offset
176+
end
177+
178+
return vec3:new(42.82, -1599.19, 29.60) -- final payphone
179+
end
180+
148181
---@return AgencyProperty?
149-
function YimHeists:GetAgencyProperty()
182+
function Mastermind:GetAgencyProperty()
150183
return self.m_properties.agency
151184
end
152185

153186
---@return vec3?
154-
function YimHeists:GetAgencyLocation()
187+
function Mastermind:GetAgencyLocation()
155188
local agency = self:GetAgencyProperty()
156189
if (not agency) then
157190
return
@@ -161,12 +194,12 @@ function YimHeists:GetAgencyLocation()
161194
end
162195

163196
---@return FieldHangarProperty?
164-
function YimHeists:GetFieldHangarProperty()
197+
function Mastermind:GetFieldHangarProperty()
165198
return self.m_properties.hangar
166199
end
167200

168201
---@return vec3?
169-
function YimHeists:GetFieldHangarLocation()
202+
function Mastermind:GetFieldHangarLocation()
170203
local hangar = self:GetFieldHangarProperty()
171204
if (not hangar) then
172205
return
@@ -175,20 +208,32 @@ function YimHeists:GetFieldHangarLocation()
175208
return hangar.coords
176209
end
177210

178-
---@return SubmarineProperty?
179-
function YimHeists:HasSubmarine()
180-
return self.m_properties.submarine
211+
---@return FacilityProperty?
212+
function Mastermind:GetFacilityProperty()
213+
return self.m_properties.facility
181214
end
182215

183-
-- ---@return vec3?
184-
-- function YimHeists:GetSubmarineLocation()
185-
-- local sub = self:HasSubmarine()
186-
-- if (not sub) then
187-
-- return
188-
-- end
216+
---@return vec3?
217+
function Mastermind:GetFacilityLocation()
218+
local facility = self:GetFacilityProperty()
219+
if (not facility) then
220+
return
221+
end
222+
223+
return facility.coords
224+
end
189225

190-
-- sub.coords = Game.Ensure3DCoords(760)
191-
-- return sub.coords
192-
-- end
226+
---@return SubmarineProperty?
227+
function Mastermind:GetSubmarine()
228+
local sub = self.m_properties.submarine
229+
if (not sub) then
230+
return
231+
end
232+
233+
local sub_global = GetSubCoordsGlobal()
234+
sub.coords = sub_global:ReadVec3()
235+
sub.heading = sub_global:At(3):ReadFloat()
236+
return sub
237+
end
193238

194-
return YimHeists
239+
return Mastermind

0 commit comments

Comments
 (0)