diff --git a/SSV2/includes/backend.lua b/SSV2/includes/backend.lua index 852890d..daa23e2 100644 --- a/SSV2/includes/backend.lua +++ b/SSV2/includes/backend.lua @@ -20,7 +20,7 @@ end ---@enum eAPIVersion Enums.eAPIVersion = { V1 = 1, -- YimMenu V1 (Lua54) - V2 = 2, -- YimMenu V2 (LuaJIT) // placeholder + V2 = 2, -- YimLuaAPI (Lua 54) L54 = 99, -- Mock environment (Lua54) } @@ -113,7 +113,7 @@ function Backend:GetAPIVersion() end if (type(script["run_in_callback"]) == "function") then - error("YmMenu V2 is not supported. If you want to run this script in GTA V Enhanced, download YimLuaAPI.") + error("YimMenuV2 is not supported. If you want to run this script in GTA V Enhanced, download YimLuaAPI.") end if (not menu_event or not menu_event.Wndproc) then @@ -480,9 +480,7 @@ function Backend:RegisterHandlers() PAD.DISABLE_CONTROL_ACTION(0, control, true) end end) - end - if (self:GetAPIVersion() == Enums.eAPIVersion.V1) then ThreadManager:RegisterLooped("SS_BACKEND", function() self:OnPlayerSwitch() self:OnSessionSwitch() diff --git a/SSV2/includes/data/globals_locals.lua b/SSV2/includes/data/globals_locals.lua index 9087e3b..e2a0c23 100644 --- a/SSV2/includes/data/globals_locals.lua +++ b/SSV2/includes/data/globals_locals.lua @@ -892,5 +892,19 @@ return { } } } + }, + request_services_global = { + description = "Request Services Global.", + file = "am_prostitute.c", -- definitely the right file to use I'm sure of it + LEGACY = { + value = 2733002, + pattern = [[Global_(\d{7})\.f_4 = 0;]], + capture_group = 1 + }, + ENHANCED = { + value = 2733138, + pattern = [[Global_(\d{7})\.f_4 = 0;]], + capture_group = 1 + } } } diff --git a/SSV2/includes/features/CasinoPacino.lua b/SSV2/includes/features/CasinoPacino.lua index 66b6b4a..0e72789 100644 --- a/SSV2/includes/features/CasinoPacino.lua +++ b/SSV2/includes/features/CasinoPacino.lua @@ -56,9 +56,9 @@ end ---@return boolean function CasinoPacino:CanAccess() - return (Backend:GetAPIVersion() == Enums.eAPIVersion.V1) - and Backend:IsUpToDate() + return Backend:IsUpToDate() and Game.IsOnline() + and not Backend:IsMockEnv() and not script.is_active("maintransition") and not NETWORK.NETWORK_IS_ACTIVITY_SESSION() end diff --git a/SSV2/includes/features/YimHeistsV1.lua b/SSV2/includes/features/YimHeistsV1.lua index 98e6af5..9a88714 100644 --- a/SSV2/includes/features/YimHeistsV1.lua +++ b/SSV2/includes/features/YimHeistsV1.lua @@ -137,4 +137,15 @@ function YimHeists:HasSubmarine() return self.m_properties.submarine end +-- ---@return vec3? +-- function YimHeists:GetSubmarineLocation() +-- local sub = self:HasSubmarine() +-- if (not sub) then +-- return +-- end + +-- sub.coords = Game.Ensure3DCoords(760) +-- return sub.coords +-- end + return YimHeists diff --git a/SSV2/includes/features/YimResupplierV3.lua b/SSV2/includes/features/YimResupplierV3.lua index 0c37886..149fa7b 100644 --- a/SSV2/includes/features/YimResupplierV3.lua +++ b/SSV2/includes/features/YimResupplierV3.lua @@ -988,8 +988,7 @@ function YRV3:MCT() end TaskWait(Game.RequestScript, "appArcadeBusinessHub") - ---@diagnostic disable-next-line: undefined-global - self.m_bhub_script_handle = (SYSTEM or BUILTIN).START_NEW_SCRIPT("appArcadeBusinessHub", 1424) -- STACK_SIZE_DEFAULT + self.m_bhub_script_handle = SYSTEM.START_NEW_SCRIPT("appArcadeBusinessHub", 1424) -- STACK_SIZE_DEFAULT SCRIPT.SET_SCRIPT_AS_NO_LONGER_NEEDED("appArcadeBusinessHub") sleep(100) diff --git a/SSV2/includes/frontend/casino_ui.lua b/SSV2/includes/frontend/casino_ui.lua index 9bdbfe5..f6b7cd6 100644 --- a/SSV2/includes/frontend/casino_ui.lua +++ b/SSV2/includes/frontend/casino_ui.lua @@ -42,15 +42,12 @@ local function drawGamblingTab() GVars.features.dunk.set_dealers_poker_cards ) - -- TODO: Fix crashing on Enhanced - if (Backend:GetAPIVersion() == Enums.eAPIVersion.V1) then - GUI:HeaderText(_T("CP_BLACKJACK_SETTINGS"), { separator = true, spacing = true }) - ImGui.BulletText(_T "CP_BLACKJACK_DEALER_FACE_DOWN_CARD") - ImGui.SameLine() - ImGui.Text(CasinoPacino:GetBJDealerCard()) - if GUI:Button(_T "CP_BLACKJACK_FORCE_DEALER_BUST") then - CasinoPacino:ForceDealerBust() - end + GUI:HeaderText(_T("CP_BLACKJACK_SETTINGS"), { separator = true, spacing = true }) + ImGui.BulletText(_T "CP_BLACKJACK_DEALER_FACE_DOWN_CARD") + ImGui.SameLine() + ImGui.Text(CasinoPacino:GetBJDealerCard()) + if GUI:Button(_T "CP_BLACKJACK_FORCE_DEALER_BUST") then + CasinoPacino:ForceDealerBust() end GUI:HeaderText(_T("CP_ROULETTE_SETTINGS"), { separator = true, spacing = true }) @@ -408,11 +405,7 @@ local function DrawDunk() if (ImGui.BeginTabBar("##dunkBar")) then if ImGui.BeginTabItem(_T("CASINO_GAMBLING_TAB")) then - if (Backend:GetAPIVersion() == Enums.eAPIVersion.V1) then - drawGamblingTab() - else - ImGui.Text(_T("CP_FEATURE_DISABLED")) - end + drawGamblingTab() ImGui.EndTabItem() end diff --git a/SSV2/includes/frontend/yhv1_ui.lua b/SSV2/includes/frontend/yhv1_ui.lua index 74635e9..e82ba1a 100644 --- a/SSV2/includes/frontend/yhv1_ui.lua +++ b/SSV2/includes/frontend/yhv1_ui.lua @@ -8,6 +8,7 @@ local YHV1 = require("includes.features.YimHeistsV1"):init() +local SGSL = require("includes.services.SGSL") local setTranslations = require("SSV2.includes.frontend.helpers.set_translations") local heistNames = { "AWT_1026", -- The Cluckin' Bell Farm Raid @@ -79,7 +80,7 @@ local function drawBasicTab() local heist_name = heist.get_name() ImGui.BulletText(heist_name) - local location = heist.get_coords() + local location = heist.get_coords() or vec3:zero() ImGui.BeginDisabled(not location) if (GUI:Button(_T("GENERIC_TELEPORT"))) then LocalPlayer:Teleport(location, false) @@ -116,18 +117,43 @@ local function drawCayoTab() return end - ImGui.BeginDisabled(sub.coords:is_zero()) + -- This is shitty, and only properly works when not near the sub. No idea what happens if multiple subs in session + -- TODO: Find and use the correct globals/offsets + local subBlip = Game.Ensure3DCoords(760) + local requestKosatka = SGSL:Get(SGSL.data.request_services_global):AsGlobal():At(613) + local subRequested = requestKosatka:ReadInt() == 1 + local subSpawned = not sub.coords:is_zero() and subBlip ~= nil + + if (subBlip or not subRequested) then + sub.coords = subBlip or vec3:zero() + end + + ImGui.BeginDisabled(not subSpawned) if (GUI:Button(_T("GENERIC_TELEPORT"))) then - LocalPlayer:Teleport(sub.coords) + LocalPlayer:Teleport(sub.coords + vec3:new(0, 0, -9.8)) -- Teleport under Kosatka end ImGui.SameLine() - if (GUI:Button(_T("GENERIC_SET_WAYPOINT"))) then Game.SetWaypointCoords(sub.coords) end ImGui.EndDisabled() + local btn_label = (subRequested) + and ImGui.TextSpinner() + or _T("YH_CAYO_REQUEST_SUB") + + ImGui.SameLine() + ImGui.BeginDisabled(subRequested or subSpawned) + if (GUI:Button(btn_label)) then + if (not LocalPlayer:IsOutside()) then + Notifier:ShowError("YHV1", _T("GENERIC_TP_INTERIOR_ERR")) + else + requestKosatka:WriteInt(1) + end + end + ImGui.EndDisabled() + -- https://www.unknowncheats.me/forum/grand-theft-auto-v/695454-edit-cayo-perico-primary-target-stat-yimmenu-v2.html -- https://www.unknowncheats.me/forum/grand-theft-auto-v/431801-cayo-perico-heist-click.html local cayo_heist_primary = stats.get_int("MPX_H4CNF_TARGET") diff --git a/SSV2/includes/frontend/yrv3/nightclub.lua b/SSV2/includes/frontend/yrv3/nightclub.lua index fe87b4a..ee31ef4 100644 --- a/SSV2/includes/frontend/yrv3/nightclub.lua +++ b/SSV2/includes/frontend/yrv3/nightclub.lua @@ -183,7 +183,7 @@ return function() ) ImGui.SetCursorPosX((ImGui.GetCursorPosX() + 40) * 0.5) - -- TODO: Fix glitchy behavior + session disconnect on Enhanced/YLAPI(?) + -- TODO: Fix glitchy behavior + session disconnect on Enhanced ImGui.BeginDisabled(Game.IsEnhanced()) ImGui.BeginDisabled(prod >= max_units) this.fast_prod_enabled, _ = GUI:CustomToggle("##fast_prod", this.fast_prod_enabled) diff --git a/SSV2/includes/lib/commands.lua b/SSV2/includes/lib/commands.lua index ec07650..b03b824 100644 --- a/SSV2/includes/lib/commands.lua +++ b/SSV2/includes/lib/commands.lua @@ -181,6 +181,56 @@ local commandRegistry = { description = "Spawns a vehicle from JSON." } }, + ["teleport"] = { + callback = function(args) + local notifE = function() + Notifier:ShowError( + "CommandExecutor", + "Missing or incorrect parameter. Usage: teleport [X] [Y] [Z]", + true, + 5 + ) + end + + if (type(args) ~= "table") then + notifE() + return + end + + local x = args[1] + local y = args[2] + local z = args[3] + + if (#args < 2) then + local wpc = Game.GetWaypointCoords() + if (not wpc) then + Notifier:ShowError( + "CommandExecutor", + "No waypoint active!", + true, + 3 + ) + return + end + + x, y, _ = wpc:unpack() + end + + if (type(x) ~= "number" or type(y) ~= "number") then + notifE() + return + end + + local coords = vec3:new(x, y, z or 0) + LocalPlayer:Teleport(coords, false, z == nil) + end, + opts = { + description = + "Teleports to given coordinates or waypoint if none given. Will try to teleport to top level if no Z argument given.\nUsage Example:\n - teleport 69 420 69\n - tp 123.456 789.1011", + args = { "X", "Y", "Optional: Z" }, + alias = { "tp" } + } + }, } return commandRegistry diff --git a/SSV2/includes/lib/translations/en-US.lua b/SSV2/includes/lib/translations/en-US.lua index 540867b..4b73fb5 100644 --- a/SSV2/includes/lib/translations/en-US.lua +++ b/SSV2/includes/lib/translations/en-US.lua @@ -728,6 +728,7 @@ return { ["YH_CAYO_TAB"] = "Cayo Perico", ["YH_SUBMARINE_NOT_OWNED"] = "Purchase a Kosatka to access the Cayo Perico Heist.", -- HIF_SUB_HELP ["YH_PREP_SKIP_NOTIF"] = "All preparation missions have been skipped. You can now start the final mission.", + ["YH_CAYO_REQUEST_SUB"] = "Request Submarine", ["YH_CAYO_TARGET_PRIMARY"] = "Primary Target", ["YH_CAYO_TARGET_SECONDARY_I"] = "Secondary Target (Island)", ["YH_CAYO_TARGET_SECONDARY_C"] = "Secondary Target (Compound)", diff --git a/SSV2/includes/modules/Player.lua b/SSV2/includes/modules/Player.lua index 1a8fa1b..acdc1a8 100644 --- a/SSV2/includes/modules/Player.lua +++ b/SSV2/includes/modules/Player.lua @@ -33,10 +33,10 @@ function Player.new(player_id) local ped_handle = PLAYER.GET_PLAYER_PED_SCRIPT_INDEX(player_id) ---@type Player + ---@diagnostic disable-next-line: assign-type-mismatch local instance = setmetatable({ m_pid = player_id, m_handle = ped_handle, - ---@diagnostic disable-next-line: param-type-mismatch }, Player) instance.m_internal = instance:Resolve() diff --git a/SSV2/includes/modules/businesses/Warehouse.lua b/SSV2/includes/modules/businesses/Warehouse.lua index 76e84eb..6713bab 100644 --- a/SSV2/includes/modules/businesses/Warehouse.lua +++ b/SSV2/includes/modules/businesses/Warehouse.lua @@ -15,35 +15,48 @@ local function GetCEOCratesValue(crates) return 0 end - if (crates == 1) then - return tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD1") + local val + if crates <= 3 then + val = tostring(crates) + elseif crates <= 5 then + val = "4" + elseif crates <= 7 then + val = "5" + elseif crates <= 9 then + val = "6" + elseif crates <= 14 then + val = "7" + elseif crates <= 19 then + val = "8" + elseif crates <= 24 then + val = "9" + elseif crates <= 29 then + val = "10" + elseif crates <= 34 then + val = "11" + elseif crates <= 39 then + val = "12" + elseif crates <= 44 then + val = "13" + elseif crates <= 49 then + val = "14" + elseif crates <= 59 then + val = "15" + elseif crates <= 69 then + val = "16" + elseif crates <= 79 then + val = "17" + elseif crates <= 89 then + val = "18" + elseif crates <= 99 then + val = "19" + elseif crates <= 110 then + val = "20" + elseif crates == 111 then + val = "21" end - if (crates == 2) then - return tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD2") * 2 -- +1 - end - - if (crates == 3) then - return tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD3") * 3 -- +1 - end - - if (crates == 4 or crates == 5) then - return tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD4") * crates -- +1 - end - - if (crates >= 6 and crates <= 9) then - return (tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD4") + math.floor((crates - 4) / 2)) * crates -- +0 - end - - if (crates >= 10 and crates <= 110) then - return (tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD7") + math.floor((crates - 10) / 5)) * crates -- +3 - end - - if (crates == 111) then - return tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD21") * 111 -- + 14 - end - - return 0 + return val and (tunables.get_int("EXEC_CONTRABAND_SALE_VALUE_THRESHOLD" .. val) * crates) or 0 end ---@enum eWarehouseType diff --git a/SSV2/includes/services/GUI.lua b/SSV2/includes/services/GUI.lua index a2aa8bf..d7c82d1 100644 --- a/SSV2/includes/services/GUI.lua +++ b/SSV2/includes/services/GUI.lua @@ -160,7 +160,8 @@ end ---@return float function GUI:GetMaxTopBarHeight() - return Game.GetScreenResolution().y * 0.115 + -- return Game.GetScreenResolution().y * 0.115 -- Incorrect sizing on anything not 1080p + return 124.2 -- 1080 * 0.115 end ---@param align? number -- 0: top center | 1: bottom center | 2: left center | 3: right center | 4: center diff --git a/dev/scripts/offsets/update_offsets.py b/dev/scripts/offsets/update_offsets.py index afb390a..03c39b5 100644 --- a/dev/scripts/offsets/update_offsets.py +++ b/dev/scripts/offsets/update_offsets.py @@ -157,7 +157,7 @@ def serialize_lua(v, indent=1): parts = [] for k, vv in v.items(): - if k == "pattern": + if (k == "pattern") or ((k == "description") and ("\n" in vv)): vv = f"[[{vv}]]" parts.append(f"{sp}{k} = {vv}") else: