Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mapfixes resource #504

Merged
merged 42 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d56d570
add mapfixes
Fernando-A-Rocha Jun 21, 2024
9e3cbb6
update comment in PLACE_BUILDINGS
Fernando-A-Rocha Jun 21, 2024
274a456
make mapfix components toggleable via server setting
Fernando-A-Rocha Jun 21, 2024
afae4c5
update map fix components table
Fernando-A-Rocha Jun 21, 2024
d960795
remove header comments from lua scripts
Fernando-A-Rocha Jun 21, 2024
672b6b7
Adding new interiors
THEGizmoOfficial Jun 23, 2024
b515bbb
WIP doherty garage and downtown atrium
Fernando-A-Rocha Jun 23, 2024
f54811d
fix whitespace in comment
Fernando-A-Rocha Jun 23, 2024
d89ed26
add doherty garage open logic
Fernando-A-Rocha Jun 23, 2024
7a27a02
One new interior and a small correction in the code
THEGizmoOfficial Jun 23, 2024
53c6838
fix triggerClientEvent spam
Fernando-A-Rocha Jun 23, 2024
6f79e03
rename garageIDsForInteriors
Fernando-A-Rocha Jun 23, 2024
bea9907
remove useless statue objects in atrium
Fernando-A-Rocha Jun 23, 2024
995cba3
better naming
Fernando-A-Rocha Jun 23, 2024
e54ea41
better comments
Fernando-A-Rocha Jun 23, 2024
c98a0b2
add comments
Fernando-A-Rocha Jun 24, 2024
523ec90
rename server_main
Fernando-A-Rocha Jun 24, 2024
3af56c2
rename client_main
Fernando-A-Rocha Jun 24, 2024
474f44a
add special pushable doors @ atrium
Fernando-A-Rocha Jun 24, 2024
91fb08d
move scripts
Fernando-A-Rocha Jun 25, 2024
ca48536
add laeIdleProj02.col fix
Fernando-A-Rocha Jun 25, 2024
28f3a67
correction in setting name
Fernando-A-Rocha Jun 25, 2024
8f7ce4b
make settings display better on admin panel
Fernando-A-Rocha Jun 25, 2024
e707787
rename some variables
Fernando-A-Rocha Jun 25, 2024
a55eb89
Repair details
THEGizmoOfficial Jun 25, 2024
e32da61
prettier format lua
Fernando-A-Rocha Jun 25, 2024
c3804ab
fix newline
Fernando-A-Rocha Jun 25, 2024
f4aa9a2
Two new collision repairs
THEGizmoOfficial Jun 25, 2024
a13eb66
Space correction
THEGizmoOfficial Jun 25, 2024
fb86ff6
comments
Fernando-A-Rocha Jun 25, 2024
322602b
fix space comments
Fernando-A-Rocha Jun 25, 2024
f4073b8
Repair of ground collisions under the bridge
THEGizmoOfficial Jun 26, 2024
9f11ace
formatting
Fernando-A-Rocha Jun 26, 2024
f0c0448
change setting to [true] instead of string true
Fernando-A-Rocha Jun 26, 2024
eaf4403
Remove model replacement :crying_cat_face:
Fernando-A-Rocha Jun 26, 2024
a64fc36
Merge remote-tracking branch 'upstream/master' into add-map-fixes
Fernando-A-Rocha Jun 26, 2024
d369c51
remove old settings
Fernando-A-Rocha Jun 27, 2024
97325f8
Update meta.xml
Fernando-A-Rocha Jun 27, 2024
87989b6
Merge remote-tracking branch 'upstream/master' into add-map-fixes
Fernando-A-Rocha Jul 2, 2024
8cef18e
make table shared
Fernando-A-Rocha Jul 2, 2024
22009cd
add mapfixes to `play` include resource
Fernando-A-Rocha Jul 2, 2024
d1a7de1
add big smoke crack palace wall
Fernando-A-Rocha Jul 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions [gameplay]/mapfixes/meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<meta>
<info author="MTA contributors (github.com/multitheftauto/mtasa-resources)" version="1.0" name="SA Map Fixes" description="This resource patches a few flaws in the default MTA world" type="script" />
<min_mta_version client="1.6.0-9.22505.0" server="1.6.0-9.22505.0"></min_mta_version>

<script src="scripts/client/main.lua" type="client"/>
<script src="scripts/server/data.lua" type="server"/>
<script src="scripts/server/main.lua" type="server"/>

<settings>
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved
<setting name="*crack_palace_interior" value="true" desc="Enable Big Smoke Crack Palace open-world interior map" accept="true,false"/>
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved
<setting name="*atrium_lobby_interior" value="true" desc="Enable Atrium lobby entrance open-world interior map" accept="true,false"/>
<setting name="*garage_doherty_interior" value="true" desc="Enable Doherty Safehouse Garage open-world interior map" accept="true,false"/>
<setting name="*nodamage_crackfactory_interior" value="true" desc="Enable Undamaged SF Crack Factory open-world interior map" accept="true,false"/>
<setting name="*laeIdleProj02" value="true" desc="Enable laeIdleProj02 (Idlewood) Buildings collision fix" accept="true,false"/>
<setting name="*mall_01_SFS" value="true" desc="Enable mall_01_SFS Buildings collision fix" accept="true,false"/>
<setting name="*aircarpark_09_SFSe" value="true" desc="Enable aircarpark_09_SFSe Tunnel collision fix" accept="true,false"/>
<setting name="*CE_groundPALO03" value="true" desc="Enable CE_groundPALO03 Bridge collision fix" accept="true,false"/>
</settings>

<file src="models/laeIdleProj02.col"/>
<file src="models/mall_01_SFS.col"/>
<file src="models/aircarpark_09_SFSe.col"/>
<file src="models/CE_groundPALO03.col"/>
</meta>
Binary file added [gameplay]/mapfixes/models/CE_groundPALO03.col
Binary file not shown.
17 changes: 17 additions & 0 deletions [gameplay]/mapfixes/models/CREDITS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Credits of the modified game models contained in this folder:

Optimized and fixed collision created by THEGizmo:
- laeIdleProj02.col
- mall_01_SFS.col
- aircarpark_09_SFSe.col
- CE_groundPALO03.col

[ List of repair details for ]
laeIdleProj02.col, mall_01_SFS.col, aircarpark_09_SFSe.col:
-- Isolated vertexes removed
-- Polygons slightly optimized
-- Holes patched

CE_groundPALO03.col:
-- Isolated vertexes removed
-- Removed polygons that caused the vehicle to jump on the bridge
Binary file not shown.
Binary file added [gameplay]/mapfixes/models/laeIdleProj02.col
Binary file not shown.
Binary file added [gameplay]/mapfixes/models/mall_01_SFS.col
Binary file not shown.
136 changes: 136 additions & 0 deletions [gameplay]/mapfixes/scripts/client/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
addEvent("mapfixes:client:loadAllComponents", true)
addEvent("mapfixes:client:togOneComponent", true)

local mapFixComponents = {}

local function loadOneMapFixComponent(name, data)
-- Restore previously replaced models if any
local modelsToReplace = data.modelsToReplace
if modelsToReplace then
for _, v in pairs(modelsToReplace) do
engineRestoreCOL(v.modelID)
engineRestoreModel(v.modelID)
end
end
-- Clear the previous elements if any
local createdElements = data.createdElements
if createdElements then
for _, element in pairs(createdElements) do
if isElement(element) then
destroyElement(element)
end
end
data.createdElements = {}
end
-- Clear the previous requested model IDs if any
local allocatedIDs = data.allocatedIDs
if allocatedIDs then
for _, modelID in pairs(allocatedIDs) do
engineFreeModel(modelID)
end
data.allocatedIDs = {}
end
-- Restore the previous removed models if any
local worldModelsToRemove = data.worldModelsToRemove
if worldModelsToRemove then
for _, v in pairs(worldModelsToRemove) do
restoreWorldModel(unpack(v))
end
end
-- Close previously opened garages if any
local garageIDsForInteriorsToOpen = data.garageIDsForInteriorsToOpen
if garageIDsForInteriorsToOpen then
for _, garageID in pairs(garageIDsForInteriorsToOpen) do
setGarageOpen(garageID, false)
end
end

-- Don't proceed if the component is disabled
if not data.enabled then
return
end

-- Replace models if any
if modelsToReplace then
for _, v in pairs(modelsToReplace) do
if v.colPath then
local colElement = engineLoadCOL("models/" .. v.colPath)
if colElement then
engineReplaceCOL(colElement, v.modelID)
if not data.createdElements then data.createdElements = {} end
data.createdElements[#data.createdElements + 1] = colElement
end
end
end
end
-- Create the new elements if any
local buildingsToSpawn = data.buildingsToSpawn
if buildingsToSpawn then
for _, v in pairs(buildingsToSpawn) do
local building = createBuilding(unpack(v))
if building then
if not data.createdElements then data.createdElements = {} end
data.createdElements[#data.createdElements + 1] = building
end
end
end
local objectsWithCustomPropertiesGroupToSpawn = data.objectsWithCustomPropertiesGroupToSpawn
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved
if objectsWithCustomPropertiesGroupToSpawn then
for _, v in pairs(objectsWithCustomPropertiesGroupToSpawn) do
if not data.allocatedIDs then data.allocatedIDs = {} end
local allocatedID = engineRequestModel("object", v.modelID)
if allocatedID then
data.allocatedIDs[#data.allocatedIDs + 1] = allocatedID
local object = createObject(allocatedID, v.x, v.y, v.z, v.rx, v.ry, v.rz)
if object then
engineSetModelPhysicalPropertiesGroup(allocatedID, v.physicalPropertiesGroup)
if not data.createdElements then data.createdElements = {} end
data.createdElements[#data.createdElements + 1] = object
end
end
end
end
-- Remove world models if any
if worldModelsToRemove then
for _, v in pairs(worldModelsToRemove) do
removeWorldModel(unpack(v))
end
end
-- Open garages if any
if garageIDsForInteriorsToOpen then
for _, garageID in pairs(garageIDsForInteriorsToOpen) do
setGarageOpen(garageID, true)
end
end
end

local function loadMapFixComponents(mapFixComponentsFromServer)
assert(type(mapFixComponentsFromServer) == "table")
mapFixComponents = mapFixComponentsFromServer
for name, data in pairs(mapFixComponents) do
loadOneMapFixComponent(name, data)
end
end
addEventHandler("mapfixes:client:loadAllComponents", localPlayer, loadMapFixComponents, false)

local function toggleOneMapFixComponent(name, enable)
assert(type(name) == "string")
assert(type(enable) == "boolean")
local data = mapFixComponents[name]
if not data then
return
end
data.enabled = (enable == true)
loadOneMapFixComponent(name, data)
if eventName ~= "onClientResourceStop" then
outputDebugString("Map fix component '" .. name .. "' is now " .. (data.enabled and "enabled" or "disabled"))
end
end
addEventHandler("mapfixes:client:togOneComponent", resourceRoot, toggleOneMapFixComponent, false)

local function unloadAllMapFixComponents()
for name, _ in pairs(mapFixComponents) do
toggleOneMapFixComponent(name, false)
end
end
addEventHandler("onClientResourceStop", resourceRoot, unloadAllMapFixComponents, false)
111 changes: 111 additions & 0 deletions [gameplay]/mapfixes/scripts/server/data.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
mapFixComponents = {
["crack_palace_interior"] = {
-- Adds the original interior of Big Smoke's Crack Palace
buildingsToSpawn = {
-- Object positions taken from carter.ipl
{ 17933, 2532.992188, -1289.789062, 39.281250, 0, 0, 0 }, -- carter-light15b
{ 17946, 2533.820312, -1290.554688, 36.945312, 0, 0, 0 }, -- carter_ground
},
},
["atrium_lobby_interior"] = {
-- Removes the doors of the atrium and places the original interior inside
buildingsToSpawn = {
-- Object positions taken from gen_int1.ipl
{ 14675, 1719.75, -1655.765625, 30.1953125, 0, 0, 0 }, -- Hotelatrium_LAn
{ 14674, 1721.632813, -1655.1875, 24.3125, 0, 0, 0 }, -- hotelferns1_LAn
},
worldModelsToRemove = {
-- Interior -1 needs to be used because these objects are spawned in Interior 13 (in lan_stream3.ipl)
-- which causes them to appear in all interiors (GTA:SA behavior)
{ 1537, 5, 1725.4, -1637.4, 19.2, -1 }, -- Gen_doorEXT16
{ 1533, 5, 1728.4, -1637.4, 19.2, -1 }, -- Gen_doorEXT12
{ 1537, 5, 1700.1, -1669.4, 19.2, -1 }, -- Gen_doorEXT16
{ 1533, 5, 1700.1, -1669.4, 19.2, -1 }, -- Gen_doorEXT12
},
objectsWithCustomPropertiesGroupToSpawn = {
{ modelID = 1533, physicalPropertiesGroup = 147, x = 1700.132812, y = -1666.40625, z = 19.210938, rx = 0, ry = -0, rz = -90 },
{ modelID = 1537, physicalPropertiesGroup = 147, x = 1700.132812, y = -1669.421875, z = 19.210938, rx = 0, ry = 0, rz = -90 },
{ modelID = 1537, physicalPropertiesGroup = 147, x = 1725.429688, y = -1637.4375, z = 19.210938, rx = 0, ry = 0, rz = -180 },
{ modelID = 1533, physicalPropertiesGroup = 147, x = 1728.445312, y = -1637.4375, z = 19.210938, rx = 0, ry = 0, rz = -180 },
},
},
["garage_doherty_interior"] = {
-- Adds the original Doherty Safehouse Garage interior
buildingsToSpawn = {
-- Object positions taken from sfse_stream5.ipl
{ 11389, -2048.11719, 166.71875, 30.97656, 0.00000, 0.00000, 0.00000 }, -- hubinterior_SFS
{ 11388, -2048.17969, 166.71875, 34.51563, 0.00000, 0.00000, 0.00000 }, -- hubintroof_SFSe
{ 11390, -2048.17969, 166.71875, 32.22656, 0.00000, 0.00000, 0.00000 }, -- hubgirders_SFSE
{ 11394, -2048.16406, 168.31250, 31.73438, 0.00000, 0.00000, 0.00000 }, -- hubgrgbeams_SFSe
{ 11391, -2056.20313, 158.54688, 29.09375, 0.00000, 0.00000, 0.00000 }, -- hubprops6_SFSe
{ 11393, -2043.51563, 161.34375, 29.33594, 0.00000, 0.00000, 0.00000 }, -- hubprops1_SFS
{ 11392, -2047.75781, 168.14063, 27.88281, 0.00000, 0.00000, 0.00000 }, -- hubfloorstains_SFSe
},
garageIDsForInteriorsToOpen = {
22, -- Mission Garage (Doherty)
},
},
["nodamage_crackfactory_interior"] = {
-- Removes the destroyed SF factory building, and adds the original interior
buildingsToSpawn = {
-- Object positions taken from crack.ipl
{ 11007, -2164.45313, -248.00000, 40.78125, 0.00000, 0.00000, 0.00000 }, -- crack_wins_SFS
{ 11085, -2164.45313, -237.61719, 41.40625, 0.00000, 0.00000, 0.00000 }, -- crack_int1
{ 11086, -2164.45313, -237.39063, 43.42188, 0.00000, 0.00000, 0.00000 }, -- crack_int2
{ 11087, -2143.22656, -261.24219, 38.09375, 0.00000, 0.00000, 0.00000 }, -- crackfactwalk
{ 11089, -2185.52344, -263.92969, 38.76563, 0.00000, 0.00000, 90 }, -- crackfacttanks2_SFS
{ 11090, -2158.82031, -266.23438, 36.22656, 0.00000, 0.00000, 90 }, -- crackfactvats_SFS
{ 11233, -2164.45313, -255.39063, 38.12500, 0.00000, 0.00000, 0.00000 }, -- crackfactwalkb
{ 11234, -2180.45313, -251.46875, 37.99219, 0.00000, 0.00000, 0.00000 }, -- crackfactwalkc
{ 11235, -2180.45313, -261.28906, 37.99219, 0.00000, 0.00000, 0.00000 }, -- crackfactwalkd
{ 11236, -2164.45313, -255.39063, 38.12500, 0.00000, 0.00000, 0.00000 }, -- crackfactwalke
{ 939, -2179.33594, -239.08594, 37.96094, 0.00000, 0.00000, 0.00000 }, -- CJ_DF_UNIT
{ 939, -2140.22656, -237.50781, 37.96094, 0.00000, 0.00000, 90 }, -- CJ_DF_UNIT
{ 942, -2159.06250, -239.06250, 37.96094, 0.00000, 0.00000, 0.00000 }, -- CJ_DF_UNIT_2
{ 942, -2174.82813, -235.56250, 37.96094, 0.00000, 0.00000, 80 }, -- CJ_DF_UNIT_2
{ 942, -2140.33594, -229.14844, 37.96094, 0.00000, 0.00000, 90 }, -- CJ_DF_UNIT_2
{ 942, -2164.20313, -236.02344, 37.96094, 0.00000, 0.00000, 90 }, -- CJ_DF_UNIT_2
{ 944, -2188.52344, -236.80469, 36.39844, 0.00000, 0.00000, 0.00000 }, -- Packing_carates04
{ 944, -2153.79688, -229.03906, 36.39844, 0.00000, 0.00000, 0.00000 }, -- Packing_carates04
{ 944, -2146.26563, -238.40625, 36.39844, 0.00000, 0.00000, -95 }, -- Packing_carates04
{ 944, -2171.10156, -235.70313, 36.39844, 0.00000, 0.00000, -175 }, -- Packing_carates04
{ 944, -2145.16406, -234.17188, 36.39844, 0.00000, 0.00000, -80 }, -- Packing_carates04
{ 944, -2146.02344, -228.50000, 36.39844, 0.00000, 0.00000, -80 }, -- Packing_carates04
{ 944, -2149.87500, -229.71875, 36.39844, 0.00000, 0.00000, 0.00000 }, -- Packing_carates04
{ 944, -2177.53906, -259.82813, 36.39844, 0.00000, 0.00000, -95 }, -- Packing_carates04
{ 944, -2175.75000, -266.33594, 36.39844, 0.00000, 0.00000, -55 }, -- Packing_carates04
{ 944, -2146.06250, -251.00781, 36.39844, 0.00000, 0.00000, -90 }, -- Packing_carates04
{ 944, -2180.39063, -247.46094, 36.39844, 0.00000, 0.00000, -90 }, -- Packing_carates04
},
worldModelsToRemove = {
{ 11088, 60, -2166.875, -236.51562, 40.85938, 0 }, -- CF_ext_dem_SFS
{ 11282, 60, -2166.875, -236.51562, 40.85938, 0 }, -- (LOD) CF_ext_dem_SFS
{ 11235, 15, -2180.4531, -261.28906, 37.99219, 0 }, -- crackfactwalkd
{ 11236, 25, -2164.4531, -255.39062, 38.125, 0 }, -- crackfactwalke
},
},
["laeIdleProj02"] = {
-- Fixes the collision of these apartment complex buildings in Idlewood
modelsToReplace = {
{ modelID = 5475, colPath = "laeIdleProj02.col" }
},
},
["mall_01_SFS"] = {
-- Fixes the collision of shopping mall building in San Fierro
modelsToReplace = {
{ modelID = 10974, colPath = "mall_01_SFS.col" }
},
},
["aircarpark_09_SFSe"] = {
-- Fixes a bollard collision in the San Fierro Airport Tunnel
modelsToReplace = {
{ modelID = 10786, colPath = "aircarpark_09_SFSe.col" }
},
},
["CE_groundPALO03"] = {
-- Fixed ground collision in Palomino Creek Red Bridge
modelsToReplace = {
{ modelID = 13101, colPath = "CE_groundPALO03.col" }
},
},
}
29 changes: 29 additions & 0 deletions [gameplay]/mapfixes/scripts/server/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- Fetch the settings on script load
for name, data in pairs(mapFixComponents) do
data.enabled = get(name) == "true"
end

local function handlePlayerResourceStart(res)
if res ~= resource then return end

triggerClientEvent(source, "mapfixes:client:loadAllComponents", source, mapFixComponents)
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved
end
addEventHandler("onPlayerResourceStart", root, handlePlayerResourceStart)

local function handleSettingChange(settingName)
settingName = settingName:gsub(getResourceName(resource) .. ("."), "")
local modifier = settingName:sub(1, 1)
if modifier == "*" or modifier == "#" or modifier == "@" then
settingName = settingName:sub(2)
end
local data = mapFixComponents[settingName]
if not data then return end

-- Fetch the new setting value
local newValue = get(settingName)
data.enabled = newValue == "true"

-- Trigger for all players
triggerClientEvent("mapfixes:client:togOneComponent", resourceRoot, settingName, data.enabled)
end
addEventHandler("onSettingChange", root, handleSettingChange, false)