diff --git a/resources/[lib]/ExtraMapTiles/MINIMAP_LOADER.gfx b/resources/[lib]/ExtraMapTiles/MINIMAP_LOADER.gfx new file mode 100644 index 0000000000..a35f4d8869 Binary files /dev/null and b/resources/[lib]/ExtraMapTiles/MINIMAP_LOADER.gfx differ diff --git a/resources/[lib]/ExtraMapTiles/client.lua b/resources/[lib]/ExtraMapTiles/client.lua new file mode 100644 index 0000000000..aa39664a05 --- /dev/null +++ b/resources/[lib]/ExtraMapTiles/client.lua @@ -0,0 +1,303 @@ +-- DO NOT MODIFY! +vBitmapTileSizeX = 4500.0 +vBitmapTileSizeY = 4500.0 +vBitmapStartX = -4140.0 +vBitmapStartY = 8400.0 + +-- Overlay ID. +overlay = 0 + +-- Will store the keys of the currently drawn tiles. +drawnTiles = {} + +-- List to store the dummy blip handles. +dummyBlips = {} + +-- Function that will create a new tile. +function createTile(tileName) + + + -- Early exit for invalid tile name. + if extraTiles[tileName] == nil then + return + end + + -- Get the tile's object. + local extraTile = extraTiles[tileName] + + if extraTile.txd == nil or extraTile.txn == nil then + return + end + + + + -- Get the texture info, alpha, centering and rotation. + local textureDictionary = extraTile.txd + local textureName = extraTile.txn + local alpha = extraTile.alpha or defaultAlpha + local centered = extraTile.centered or false + local rotation = extraTile.rotation or 0.0 + + -- Load the required texture. + loadTextureDictionary(textureDictionary) + + -- Get the width and height of the texture. + local xTexture, yTexture, _ = table.unpack(GetTextureResolution(textureDictionary, textureName)) + + -- Compute the scale ratios. + local xScale = vBitmapTileSizeX / xTexture * 100 + local yScale = vBitmapTileSizeY / yTexture * 100 + + -- Tile was configurated to use XY coordinates. + if extraTile.x ~= nil and extraTile.y ~= nil then + + -- Compute offsets from given coordinates since other functionalities + -- such as extendPauseMenuMapBounds() work with offsets, not with XY coords directly. + extraTile.xOffset = (extraTile.x - vBitmapStartX) / vBitmapTileSizeX + extraTile.yOffset = (extraTile.y - vBitmapStartY) / vBitmapTileSizeY + end + + + -- Get the offsets, convert to float. + local xOffset = extraTile.xOffset * 1.0 + local yOffset = extraTile.yOffset * (-1.0) + + + -- Compute X and Y coordinates based on the offsets. + local x = vBitmapStartX + xOffset * vBitmapTileSizeX + local y = vBitmapStartY - yOffset * vBitmapTileSizeY + + + + -- Convert alpha to an INT. + alpha = math.floor(math.abs(alpha)) + -- Convert rotation to FLOAT. + rotation = rotation * 1.0 + + -- Call the Scaleform function. + CallMinimapScaleformFunction(overlay, "ADD_SCALED_OVERLAY") + -- Push the parameters onto the stack. + ScaleformMovieMethodAddParamTextureNameString(textureDictionary) + ScaleformMovieMethodAddParamTextureNameString(textureName) + ScaleformMovieMethodAddParamFloat(x) + ScaleformMovieMethodAddParamFloat(y) + ScaleformMovieMethodAddParamFloat(rotation) + ScaleformMovieMethodAddParamFloat(xScale) + ScaleformMovieMethodAddParamFloat(yScale) + ScaleformMovieMethodAddParamInt(alpha) + ScaleformMovieMethodAddParamBool(centered) + EndScaleformMovieMethod() + + -- Mark the texture as no longer needed. + SetStreamedTextureDictAsNoLongerNeeded(textureDictionary) + + -- Add it to the drawn tiles table. + table.insert(drawnTiles, tileName) +end + +-- Function that deletes a tile. +function deleteTile(tileName) + + local id = -1 + + for i = 1, #drawnTiles do + if drawnTiles[i] == tileName then + id = i + table.remove(drawnTiles, id) + break + end + end + + if id == -1 then + return + end + + -- Call the remove scaleform function. + CallMinimapScaleformFunction(overlay, "REM_OVERLAY"); + -- Push the parameter onto the stack. + ScaleformMovieMethodAddParamInt(id - 1) + EndScaleformMovieMethod() +end + +-- Function that will draw all tiles in the extraTiles table. +function createAllTiles() + + local extraTilesNames = getTableKeys(extraTiles) + if extraTilesNames == nil then + return + end + + -- Iterate all extra tiles. + for i = 1, #extraTilesNames do + + -- Get the current tile's key. + local tileName = extraTilesNames[i] + + -- Create the new tile. + createTile(tileName) + end + + if #dummyBlips == 0 then + extendPauseMenuMapBounds() + end +end + +-- Function that will delete all tiles that are currently drawn. +function deleteAllTiles() + + -- Delete the tile at index 1. The table will shift the remaining + -- elements' indices. + for i = 1, #drawnTiles do + deleteTile(drawnTiles[1]) + end + + if #dummyBlips ~= 0 then + resetPauseMenuMapBounds() + end +end + +-- Function that returns true if the tile with the specified name is currently drawn +-- or false otherwise. +function isTileDrawn(tileName) + if tileName == nil then + return false + end + + for i = 1, #drawnTiles do + if drawnTiles[i] == tileName then + return true + end + end + + return false +end + +-- Function that will let you move outside the normal bounds of the +-- pause menu map. +function extendPauseMenuMapBounds() + + if #dummyBlips ~= 0 then + resetPauseMenuMapBounds() + end + + + local extraTilesNames = drawnTiles + if extraTilesNames == nil then + return + end + + -- Set starting values. + local xMinOffset = extraTiles[extraTilesNames[1]].xOffset or 0 + local xMaxOffset = extraTiles[extraTilesNames[1]].xOffset or 0 + local yMinOffset = extraTiles[extraTilesNames[1]].yOffset or 0 + local yMaxOffset = extraTiles[extraTilesNames[1]].yOffset or 0 + + -- Find min and max values for xOffset and yOffset. + for i = 1, #extraTilesNames do + local extraTile = extraTiles[extraTilesNames[i]] + + if extraTile.xOffset < xMinOffset then + xMinOffset = extraTile.xOffset + end + + if extraTile.xOffset > xMaxOffset then + xMaxOffset = extraTile.xOffset + end + + if extraTile.yOffset < yMinOffset then + yMinOffset = extraTile.yOffset + end + + if extraTile.yOffset > yMaxOffset then + yMaxOffset = extraTile.yOffset + end + end + + -- Create 4 invisible blips at the corners of the furthest tiles + -- to create something like a bounding box in which all other + -- tiles are included. This could possibly be improved to use 2 + -- blips instead of 4. + + createDummyBlip(vBitmapStartX + xMinOffset * vBitmapTileSizeX - vBitmapTileSizeX / 2, + vBitmapStartY + yMaxOffset * vBitmapTileSizeY + vBitmapTileSizeY / 2) + + createDummyBlip(vBitmapStartX + xMinOffset * vBitmapTileSizeX - vBitmapTileSizeX / 2, + vBitmapStartY + (yMinOffset - 1) * vBitmapTileSizeY - vBitmapTileSizeY / 2) + + createDummyBlip(vBitmapStartX + (xMaxOffset + 1) * vBitmapTileSizeX + vBitmapTileSizeX / 2, + vBitmapStartY + (yMinOffset - 1) * vBitmapTileSizeY - vBitmapTileSizeY / 2) + + createDummyBlip(vBitmapStartX + (xMaxOffset + 1) * vBitmapTileSizeX + vBitmapTileSizeX / 2, + vBitmapStartY + yMaxOffset * vBitmapTileSizeY + vBitmapTileSizeY / 2) +end + +-- This function will reset the pause menu map's bounds to the default. +function resetPauseMenuMapBounds() + for i = 1, #dummyBlips do + RemoveBlip(dummyBlips[i]) + end + + dummyBlips = {} +end + +-- Function that will create an invisible blip. +function createDummyBlip(x, y) + local dummyBlip = AddBlipForCoord(x, y, 1.0) + SetBlipDisplay(dummyBlip, 4) + SetBlipAlpha(dummyBlip, 0) + + table.insert(dummyBlips, dummyBlip) +end + +-- Loads a minimap overlay from a given path. +function loadMinimapOverlay(gfxFilePath) + local _overlay = AddMinimapOverlay(gfxFilePath) + + while not HasMinimapOverlayLoaded(_overlay) do + Citizen.Wait(0) + end + + SetMinimapOverlayDisplay(_overlay, 0.0, 0.0, 100.0, 100.0, 100.0) + + return _overlay +end + +-- Loads a texture dictionary into memory. +function loadTextureDictionary(textureDictionary) + if not HasStreamedTextureDictLoaded(textureDictionary) then + RequestStreamedTextureDict(textureDictionary, false) + while not HasStreamedTextureDictLoaded(textureDictionary) do + Citizen.Wait(0) + end + end +end + +-- Function that converts the keys of a dictionary to an alphabetically-sorted list. +function getTableKeys(keyset) + local list = {} + + for key, _ in pairs(keyset) do + table.insert(list, key) + end + + table.sort(list) + + return list +end + +exports("createAllTiles", createAllTiles) +exports("deleteAllTiles", deleteAllTiles) +exports("createTile", createTile) +exports("deleteTile", deleteTile) +exports("extendPauseMenuMapBounds", extendPauseMenuMapBounds) +exports("resetPauseMenuMapBounds", resetPauseMenuMapBounds) +exports("isTileDrawn", isTileDrawn) + + +Citizen.CreateThread(function() + -- Load the minimap overlay. + overlay = loadMinimapOverlay("MINIMAP_LOADER.gfx") + + -- Draw all tiles. + createAllTiles() +end) diff --git a/resources/[lib]/ExtraMapTiles/config.lua b/resources/[lib]/ExtraMapTiles/config.lua new file mode 100644 index 0000000000..abe348001b --- /dev/null +++ b/resources/[lib]/ExtraMapTiles/config.lua @@ -0,0 +1,53 @@ +--[[ + This is the offsets table. This tells the script where to create new map tiles. + The origin point from which offset positions are calculated is defined by the + vBitmapStartX and vBitmapStartY, same as in the minimap.ymt file. Do not modify + the vBitmapStartX and vBitmapStartY, or the script will not function correctly. + + The keys of each tile can be arbitrary, maybe something so you can identify them, + but they have to be unique. + + xOffset represents the number of tiles away from the origin point to place the new + tile on the X axis. A positive xOffset will place the new tile to the right of the + origin on the X axis and to the left for negative values. + + Same for yOffset, but on the Y axis. Positive values place it above the origin and + negative values place it below the origin point. + + If needed, xOffset and yOffset you can omit the xOffset and yOffset fields and use + just x and y fields that represent in-game XY coordinates. + + Remember that the anchor point of all new tiles is the top left corner of the tile, + unless setting centered to true. + + Other optional fields include are: + - alpha: sets the alpha of the tile. Ranges from 0 to 100. + - rotation: Sets the rotation of the tile in a clockwise direction. Ranges from 0 to 360. + - centered: Sets the tile in the center of the chosen point. Can be true or false. + + + Important: By default, one tile's dimensions are 4500x4500. This is useful when creating + a grid of tiles using in-game XY coordinates so that you can perfectly align them together. + +]] + +-- Extra tiles can be placed at any offets, they don't have to be "connected" to the default +-- map's tiles. +extraTiles = { + [1] = {x = 4730.0, y = -5145.0, txd = "tile_cayo", txn = "cayo", centered = true}, + + -- 2 tiles in the top left corner of the default map. + --[1] = {xOffset = -1, yOffset = 1, txd = "minimap_extra_tile_1", txn = "extra_tile_1"}, + --[2] = {xOffset = -2, yOffset = 1, txd = "minimap_extra_tile_1", txn = "extra_tile_1", alpha = 50}, + + -- Another tile in the middle, on the right side of the default map, but rotated 25 degrees clockwise + --[3] = {xOffset = 2, yOffset = 0, txd = "minimap_extra_tile_2", txn = "extra_tile_2", alpha = 70, rotation = 25}, + + -- Tiles created using in game coordinates instead of offsets. + --[4] = {x = 0.0, y = 0.0, txd = "minimap_extra_tile_1", txn = "extra_tile_1", centered = true}, + --[5] = {x = 4500.0, y = 0.0, txd = "minimap_extra_tile_1", txn = "extra_tile_1"}, +} + + +-- Default alpha value that will be used if not specified in the extraTiles table. +defaultAlpha = 100 diff --git a/resources/[lib]/ExtraMapTiles/fxmanifest.lua b/resources/[lib]/ExtraMapTiles/fxmanifest.lua new file mode 100644 index 0000000000..e0dbe1f4db --- /dev/null +++ b/resources/[lib]/ExtraMapTiles/fxmanifest.lua @@ -0,0 +1,20 @@ +-- Manifest data. +fx_version "cerulean" +games {"gta5"} +lua54 "yes" + +-- Resource information. +name "Extra Map Tiles" +description "Adds extra tiles for textures on the minimap and pause menu map." +version "1.2.0" +author "L1CKS" + +-- Files. +files { + "MINIMAP_LOADER.gfx" -- Always first in the list. +} + +client_scripts { + "config.lua", + "client.lua" +} diff --git a/resources/[lib]/ExtraMapTiles/stream/tile_cayo.ytd b/resources/[lib]/ExtraMapTiles/stream/tile_cayo.ytd new file mode 100644 index 0000000000..88358f8c70 Binary files /dev/null and b/resources/[lib]/ExtraMapTiles/stream/tile_cayo.ytd differ diff --git a/resources/[soz]/soz-core/src/client/world/cayo.map.provider.ts b/resources/[soz]/soz-core/src/client/world/cayo.map.provider.ts deleted file mode 100644 index da96dff93d..0000000000 --- a/resources/[soz]/soz-core/src/client/world/cayo.map.provider.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Provider } from '@core/decorators/provider'; -import { Once, OnceStep } from '@public/core/decorators/event'; -import { Inject } from '@public/core/decorators/injectable'; - -import { BlipFactory } from '../blip'; - -@Provider() -export class CayoMapProvider { - @Inject(BlipFactory) - public blipFactory: BlipFactory; - - private isCloseToCayo = false; - private isCayoMinimapLoaded = false; - - @Once(OnceStep.Start) - public init() { - //dummy blip to able to move radar to the bottom right of cayo - const blipid = 'cayo_fake_blip'; - if (this.blipFactory.exist(blipid)) { - return; - } - - this.blipFactory.create(blipid, { - coords: { x: 5942.1, y: -6271.1 }, - name: 'Cayo Perico', - sprite: 575, - display: 4, - scale: 0.000001, - color: 0, - range: true, - }); - } - - /* - //Disable as it causes lags when opening map - @Tick(TickInterval.EVERY_FRAME) - public async displayLoop() { - if (IsPauseMenuActive() && !IsMinimapInInterior()) { - SetRadarAsExteriorThisFrame(); - SetRadarAsInteriorThisFrame(GetHashKey('h4_fake_islandx'), 4700.0, -5145.0, 0, 0); - } else { - await wait(500); - } - } - */ -} diff --git a/resources/[soz]/soz-core/src/client/world/world.module.ts b/resources/[soz]/soz-core/src/client/world/world.module.ts index 715b47fb7d..d2eb555bb5 100644 --- a/resources/[soz]/soz-core/src/client/world/world.module.ts +++ b/resources/[soz]/soz-core/src/client/world/world.module.ts @@ -1,7 +1,6 @@ import { Module } from '../../core/decorators/module'; import { BlipFactory } from '../blip'; -import { CayoMapProvider } from './cayo.map.provider'; @Module({ - providers: [CayoMapProvider, BlipFactory], + providers: [BlipFactory], }) export class WorldModule {} diff --git a/resources/[soz]/soz-map/client/cayo-perico.lua b/resources/[soz]/soz-map/client/cayo-perico.lua index 63b4f23743..2462f4da41 100644 --- a/resources/[soz]/soz-map/client/cayo-perico.lua +++ b/resources/[soz]/soz-map/client/cayo-perico.lua @@ -353,22 +353,24 @@ CreateThread(function() if #(pCoords - islandCoords) < 2000.0 then if not islandLoaded then SetDeepOceanScaler(0.0) - Citizen.InvokeNative(0xF74B1FFA4A15FBEA, 1) -- island path nodes (from Disquse) + SetAiGlobalPathNodesType(1) -- island path nodes (from Disquse) SetScenarioGroupEnabled("Heist_Island_Peds", 1) SetAudioFlag("PlayerOnDLCHeist4Island", 1) SetAmbientZoneListStatePersistent("AZL_DLC_Hei4_Island_Zones", 1, 1) SetAmbientZoneListStatePersistent("AZL_DLC_Hei4_Island_Disabled_Zones", 0, 1) + exports["ExtraMapTiles"]:deleteTile(1) islandLoaded = true end else if islandLoaded then islandLoaded = false ResetDeepOceanScaler() - Citizen.InvokeNative(0xF74B1FFA4A15FBEA, 0) + SetAiGlobalPathNodesType(0) SetScenarioGroupEnabled("Heist_Island_Peds", 0) SetAudioFlag("PlayerOnDLCHeist4Island", 0) SetAmbientZoneListStatePersistent("AZL_DLC_Hei4_Island_Zones", 0, 0) SetAmbientZoneListStatePersistent("AZL_DLC_Hei4_Island_Disabled_Zones", 1, 0) + exports["ExtraMapTiles"]:createTile(1) end end