Skip to content

Commit dfff7d7

Browse files
authored
Merge pull request #107 from How-Bout-No/feature/enhanced-compat
feat: Add YHV1 cooldowns and enable features allowed with new YLAPI
2 parents 1a72c29 + 0b1f213 commit dfff7d7

17 files changed

Lines changed: 376 additions & 146 deletions

File tree

SSV2/includes/backend.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end
2020
---@enum eAPIVersion
2121
Enums.eAPIVersion = {
2222
V1 = 1, -- YimMenu V1 (Lua54)
23-
V2 = 2, -- YimMenu V2 (LuaJIT) // placeholder
23+
V2 = 2, -- YimLuaAPI (Lua 54)
2424
L54 = 99, -- Mock environment (Lua54)
2525
}
2626

@@ -113,7 +113,7 @@ function Backend:GetAPIVersion()
113113
end
114114

115115
if (type(script["run_in_callback"]) == "function") then
116-
error("YmMenu V2 is not supported. If you want to run this script in GTA V Enhanced, download YimLuaAPI.")
116+
error("YimMenuV2 is not supported. If you want to run this script in GTA V Enhanced, download YimLuaAPI.")
117117
end
118118

119119
if (not menu_event or not menu_event.Wndproc) then
@@ -480,9 +480,7 @@ function Backend:RegisterHandlers()
480480
PAD.DISABLE_CONTROL_ACTION(0, control, true)
481481
end
482482
end)
483-
end
484483

485-
if (self:GetAPIVersion() == Enums.eAPIVersion.V1) then
486484
ThreadManager:RegisterLooped("SS_BACKEND", function()
487485
self:OnPlayerSwitch()
488486
self:OnSessionSwitch()

SSV2/includes/data/config.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ local Config <const> = {
276276
slot_machine_cap = 0,
277277
autoplay_slots_delay = 500,
278278
},
279+
yim_heists = {
280+
cfr_cd = false,
281+
knoway_cd = false,
282+
dre_cd = false,
283+
ogfa_cd = false,
284+
cayo_cd = false,
285+
},
279286
yrv3 = {
280287
autofill_delay = 500,
281288
auto_sell = false,
@@ -289,7 +296,6 @@ local Config <const> = {
289296
ceo_crate_sell_cd = false,
290297
dax_work_cd = false,
291298
garment_rob_cd = false,
292-
cfr_cd = false,
293299
cwash_legal_work_cd = false,
294300
cwash_illegal_work_cd = false,
295301
weedshop_legal_work_cd = false,

SSV2/includes/data/globals_locals.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,5 +892,19 @@ return {
892892
}
893893
}
894894
}
895+
},
896+
request_services_global = {
897+
description = "Request Services Global.",
898+
file = "am_prostitute.c", -- definitely the right file to use I'm sure of it
899+
LEGACY = {
900+
value = 2733002,
901+
pattern = [[Global_(\d{7})\.f_4 = 0;]],
902+
capture_group = 1
903+
},
904+
ENHANCED = {
905+
value = 2733138,
906+
pattern = [[Global_(\d{7})\.f_4 = 0;]],
907+
capture_group = 1
908+
}
895909
}
896910
}

SSV2/includes/data/yrv3_data.lua

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,6 @@ local RawBusinessData <const> = {
157157
end
158158
end
159159
},
160-
["cfr_cd"] = {
161-
dirty = false,
162-
gstate = function()
163-
return GVars.features.yrv3.cfr_cd
164-
end,
165-
onEnable = function()
166-
if (stats.get_int("SALV23_CFR_COOLDOWN") > 0) then
167-
stats.set_int("SALV23_CFR_COOLDOWN", 0)
168-
end
169-
end
170-
},
171160
["cwash_legal_work_cd"] = {
172161
dirty = false,
173162
gstate = function()
@@ -268,6 +257,64 @@ local RawBusinessData <const> = {
268257
end
269258
end
270259
},
260+
["cfr_cd"] = {
261+
dirty = false,
262+
gstate = function()
263+
return GVars.features.yim_heists.cfr_cd
264+
end,
265+
onEnable = function()
266+
if (stats.get_int("SALV23_CFR_COOLDOWN") > 0) then
267+
stats.set_int("SALV23_CFR_COOLDOWN", 0)
268+
end
269+
end
270+
},
271+
["knoway_cd"] = {
272+
dirty = false,
273+
gstate = function()
274+
return GVars.features.yim_heists.knoway_cd
275+
end,
276+
onEnable = function()
277+
if (stats.get_int("MPX_M25_AVI_MISSION_CD") > 0) then
278+
stats.set_int("MPX_M25_AVI_MISSION_CD", 0)
279+
end
280+
end
281+
},
282+
["dre_cd"] = {
283+
dirty = false,
284+
gstate = function()
285+
return GVars.features.yim_heists.dre_cd
286+
end,
287+
onEnable = function()
288+
if (stats.get_int("MPX_FIXER_STORY_COOLDOWN") > 0) then
289+
stats.set_int("MPX_FIXER_STORY_COOLDOWN", 0)
290+
end
291+
end
292+
},
293+
["ogfa_cd"] = {
294+
dirty = false,
295+
gstate = function()
296+
return GVars.features.yim_heists.ogfa_cd
297+
end,
298+
onEnable = function()
299+
if (stats.get_int("MPX_HACKER24_MFM_COOLDOWN") > 0) then
300+
stats.set_int("MPX_HACKER24_MFM_COOLDOWN", 0)
301+
end
302+
end
303+
},
304+
["cayo_cd"] = {
305+
dirty = false,
306+
gstate = function()
307+
return GVars.features.yim_heists.cayo_cd
308+
end,
309+
onEnable = function()
310+
if (stats.get_int("MPX_H4_COOLDOWN") > 0) then
311+
stats.set_int("MPX_H4_COOLDOWN", 0)
312+
end
313+
if (stats.get_int("MPX_H4_COOLDOWN_HARD") > 0) then
314+
stats.set_int("MPX_H4_COOLDOWN_HARD", 0)
315+
end
316+
end
317+
},
271318
},
272319
SellScripts = {
273320
["gb_smuggler"] = { -- air

SSV2/includes/features/CasinoPacino.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ end
5656

5757
---@return boolean
5858
function CasinoPacino:CanAccess()
59-
return (Backend:GetAPIVersion() == Enums.eAPIVersion.V1)
60-
and Backend:IsUpToDate()
59+
return Backend:IsUpToDate()
6160
and Game.IsOnline()
61+
and not Backend:IsMockEnv()
6262
and not script.is_active("maintransition")
6363
and not NETWORK.NETWORK_IS_ACTIVITY_SESSION()
6464
end

SSV2/includes/features/YimHeistsV1.lua

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@
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+
---@class HeistStat
11+
---@field public name string
12+
---@field public val integer
13+
---@field public cooldown_name string
14+
---@field public cooldown_gvar string GVar path name
15+
1016
---@class HeistInfo
1117
---@field public get_name fun(): string
1218
---@field public get_coords fun(): vec3?
13-
---@field public stat { name: string, val: integer}
14-
---@field public optInfo? string
19+
---@field public stat HeistStat
20+
---@field public opt_info? string Optional info to provide to a tooltip, typically a starting requirement that needs to be done manually
1521

1622
---@class GenericProperty
1723
---@field public name string
@@ -57,6 +63,43 @@ function YimHeists:SkipPrep(statName, statVal, notifTitle)
5763
Notifier:ShowSuccess(notifTitle, _T("YH_PREP_SKIP_NOTIF"))
5864
end
5965

66+
-- https://www.unknowncheats.me/forum/4489469-post16.html EXCEPT setting values as that's greater risk
67+
---@param type string I or C
68+
---@param index integer
69+
function YimHeists:SetSecondaryTargets(type, index)
70+
local secondary_targets = { "CASH", "WEED", "COKE", "GOLD" }
71+
local targets = { 0, 0, 0, 0 }
72+
targets[index] = -1
73+
74+
for st = 1, #secondary_targets do
75+
local stat_name = _F("MPX_H4LOOT_%s_%s", secondary_targets[st], type)
76+
stats.set_int(stat_name, targets[st])
77+
stats.set_int(stat_name .. "_SCOPED", targets[st])
78+
end
79+
80+
stats.set_int("MPX_H4LOOT_PAINT", -1) -- Not really any reason to have an option for paintings
81+
stats.set_int("MPX_H4LOOT_PAINT_SCOPED", -1)
82+
end
83+
84+
---@return integer, integer
85+
function YimHeists:GetSecondaryTargets()
86+
local secondary_targets = { "CASH", "WEED", "COKE", "GOLD" }
87+
local return_i
88+
local return_c
89+
90+
for st = 1, #secondary_targets do
91+
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
94+
end
95+
if (stats.get_int(stat_name .. "_C") == -1) then
96+
return_c = st - 1
97+
end
98+
end
99+
100+
return return_i or -1, return_c or -1
101+
end
102+
60103
function YimHeists:ReadPropertyData()
61104
ThreadManager:Run(function()
62105
-- a better approach to this would be to read transition state.
@@ -137,4 +180,15 @@ function YimHeists:HasSubmarine()
137180
return self.m_properties.submarine
138181
end
139182

183+
-- ---@return vec3?
184+
-- function YimHeists:GetSubmarineLocation()
185+
-- local sub = self:HasSubmarine()
186+
-- if (not sub) then
187+
-- return
188+
-- end
189+
190+
-- sub.coords = Game.Ensure3DCoords(760)
191+
-- return sub.coords
192+
-- end
193+
140194
return YimHeists

SSV2/includes/features/YimResupplierV3.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,7 @@ function YRV3:MCT()
988988
end
989989

990990
TaskWait(Game.RequestScript, "appArcadeBusinessHub")
991-
---@diagnostic disable-next-line: undefined-global
992-
self.m_bhub_script_handle = (SYSTEM or BUILTIN).START_NEW_SCRIPT("appArcadeBusinessHub", 1424) -- STACK_SIZE_DEFAULT
991+
self.m_bhub_script_handle = SYSTEM.START_NEW_SCRIPT("appArcadeBusinessHub", 1424) -- STACK_SIZE_DEFAULT
993992
SCRIPT.SET_SCRIPT_AS_NO_LONGER_NEEDED("appArcadeBusinessHub")
994993
sleep(100)
995994

SSV2/includes/frontend/casino_ui.lua

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,12 @@ local function drawGamblingTab()
4242
GVars.features.dunk.set_dealers_poker_cards
4343
)
4444

45-
-- TODO: Fix crashing on Enhanced
46-
if (Backend:GetAPIVersion() == Enums.eAPIVersion.V1) then
47-
GUI:HeaderText(_T("CP_BLACKJACK_SETTINGS"), { separator = true, spacing = true })
48-
ImGui.BulletText(_T "CP_BLACKJACK_DEALER_FACE_DOWN_CARD")
49-
ImGui.SameLine()
50-
ImGui.Text(CasinoPacino:GetBJDealerCard())
51-
if GUI:Button(_T "CP_BLACKJACK_FORCE_DEALER_BUST") then
52-
CasinoPacino:ForceDealerBust()
53-
end
45+
GUI:HeaderText(_T("CP_BLACKJACK_SETTINGS"), { separator = true, spacing = true })
46+
ImGui.BulletText(_T "CP_BLACKJACK_DEALER_FACE_DOWN_CARD")
47+
ImGui.SameLine()
48+
ImGui.Text(CasinoPacino:GetBJDealerCard())
49+
if GUI:Button(_T "CP_BLACKJACK_FORCE_DEALER_BUST") then
50+
CasinoPacino:ForceDealerBust()
5451
end
5552

5653
GUI:HeaderText(_T("CP_ROULETTE_SETTINGS"), { separator = true, spacing = true })
@@ -408,11 +405,7 @@ local function DrawDunk()
408405

409406
if (ImGui.BeginTabBar("##dunkBar")) then
410407
if ImGui.BeginTabItem(_T("CASINO_GAMBLING_TAB")) then
411-
if (Backend:GetAPIVersion() == Enums.eAPIVersion.V1) then
412-
drawGamblingTab()
413-
else
414-
ImGui.Text(_T("CP_FEATURE_DISABLED"))
415-
end
408+
drawGamblingTab()
416409
ImGui.EndTabItem()
417410
end
418411

0 commit comments

Comments
 (0)