Jump to content

Getting the right coordinates from map.zon file


Przemcio

Recommended Posts

Hello! I'm trying to fill San Fierro with radar zones with createRadarArea using map.zon file from GTA: SA's data folder. According to this, districts coord in map.zon are usually starting from lower left corner and usually ends at upper right, and it's exactly my issue.

 

As map.zon file doesn't have clear districts names, I've dwelled into the code of MTA: SA and found this, then I've made a simple script to automate the work for me:

 

local districts =
			{
				{-2741, 1268, 0, -2533, 1490, 200, "Battery Point"},
				{-2741, 1659, 0, -2616, 2175, 200, "Gant Bridge"},
    			{-2741, 1490, 0, -2616, 1659, 200, "Gant Bridge"},
    			{-1339, 828, -89, -1213, 1057, 110, "Garver Bridge"},
			    {-1213, 950, -89, -1087, 1178, 110, "Garver Bridge"},
			    {-1499, 696, -179, -1339, 925, 20, "Garver Bridge"},
			    {-2533, 968, 0, -2274, 1358, 200, "Juniper Hollow"},
			    {-2741, 793, 0, -2533, 1268, 200, "Paradiso"},
			    {-2533, 1358, 0, -1996, 1501, 200, "Esplanade North"},
    			{-1996, 1358, 0, -1524, 1592, 200, "Esplanade North"},
    			{-1982, 1274, 0, -1524, 1358, 200, "Esplanade North"},
    			{-1620, 1176, 0, -1580, 1274, 200, "Esplanade East"},
   				{-1580, 1025, 0, -1499, 1274, 200, "Esplanade East"},
    			{-1499, 578, -79, -1339, 1274, 20, "Esplanade East"},
    			{-1871, 744, 0, -1701, 1176, 300, "Financial"},
    			{-2274, 744, 0, -1982, 1358, 200, "Calton Heights"},
    			{-2274, 578, 0, -2078, 744, 200, "Chinatown"},
    			{-2533, 578, 0, -2274, 968, 200, "Juniper Hill"},
    			{-2994, 458, 0, -2741, 1339, 200, "Palisades"},
    			{-2741, 458, 0, -2533, 793, 200, "Santa Flora"},
    			{-2867, 277, 0, -2593, 458, 200, "City Hall"},
    			{-2533, 458, 0, -2329, 578, 200, "Queens"},
    			{-2593, 54, 0, -2411, 458, 200, "Queens"},
    			{-2411, 373, 0, -2253, 458, 200, "Queens"},
    			{-2329, 458, 0, -1993, 578, 200, "King's"},
    			{-2411, 265, 0, -1993, 373, 200, "King's"},
    			{-2253, 373, 0, -1993, 458, 200, "King's"},
    			{-1794, 249, 0, -1242, 578, 200, "Easter Basin"},
    			{-1794, -50, 0, -1499, 249, 200, "Easter Basin"},
    			{-2270, -324, 0, -1794, -222, 200, "Doherty"},
   			 	{-2173, -222, 0, -1794, 265, 200, "Doherty"},
   			 	{-2007, 56, 0, -1922, 224, 100, "Cranberry Station"},
   			 	{-2411, -222, 0, -2173, 265, 200, "Garcia"},
   			 	{-2395, -222, 0, -2354, -204, 200, "Garcia"},
   			 	{-2593, -222, 0, -2411, 54, 200, "Hashbury"},
   			 	{-2994, 277, 0, -2867, 458, 200, "Ocean Flats"},
    			{-2994, -222, 0, -2593, 277, 200, "Ocean Flats"},
   			 	{-2994, -430, 0, -2831, -222, 200, "Ocean Flats"},
   			 	{-2646, -355, 0, -2270, -222, 200, "Avispa Country Club"},
    			{-2831, -430, 0, -2646, -222, 200, "Avispa Country Club"},
    			{-2361, -417, 0, -2270, -355, 200, "Avispa Country Club"},
    			{-2667, -302, -28, -2646, -262, 71, "Avispa Country Club"},
    			{-2470, -355, 0, -2270, -318, 46, "Avispa Country Club"},
    			{-2550, -355, 0, -2470, -318, 39, "Avispa Country Club"},
    			{-2994, -811, 0, -2178, -430, 200, "Missionary Hill"},
    			{-2270, -430, 0, -2178, -324, 200, "Foster Valley"},
    			{-2178, -599, 0, -1794, -324, 200, "Foster Valley"},
    			{-2178, -1115, 0, -1794, -599, 200, "Foster Valley"},
    			{-2178, -1250, 0, -1794, -1115, 200, "Foster Valley"},
    			{-1499, -50, 0, -1242, 249, 200, "Easter Bay Airport"},
    			{-1982, 744, 0, -1871, 1274, 200, "Downtown"},
			    {-1871, 1176, 0, -1620, 1274, 200, "Downtown"},
			    {-1700, 744, 0, -1580, 1176, 200, "Downtown"},
			    {-1580, 744, 0, -1499, 1025, 200, "Downtown"},
			    {-2078, 578, 0, -1499, 744, 200, "Downtown"},
			    {-1993, 265, 0, -1794, 578, 200, "Downtown"}
			}
			
			local file = fileOpen("output.lua", false)

			for i = 1, #districts
			do
				fileWrite(file, "createRadarArea(" .. tostring(districts[i][1]) .. ", " .. tostring(districts[i][2]) .. ", " .. tostring(math.abs(districts[i][1]) - math.abs(districts[i][4])) .. ", " .. tostring(math.abs(districts[i][2]) - math.abs(districts[i][5])) .. ", " .. tostring(math.random(255)) .. ", " .. tostring(math.random(255)) .. ", " .. tostring(math.random(255)) .. ", 255) -- " .. districts[i][7] .. "\n")
			end

			fileClose(file)

 

And the output is this:

 

createRadarArea(-2741, 1268, 208, -222, 215, 177, 102, 255) -- Battery Point
			createRadarArea(-2741, 1659, 125, -516, 67, 2, 135, 255) -- Gant Bridge
			createRadarArea(-2741, 1490, 125, -169, 244, 102, 62, 255) -- Gant Bridge
			createRadarArea(-1339, 828, 126, -229, 150, 66, 175, 255) -- Garver Bridge
			createRadarArea(-1213, 950, 126, -228, 242, 112, 228, 255) -- Garver Bridge
			createRadarArea(-1499, 696, 160, -229, 2, 240, 154, 255) -- Garver Bridge
			createRadarArea(-2533, 968, 259, -390, 201, 148, 37, 255) -- Juniper Hollow
			createRadarArea(-2741, 793, 208, -475, 57, 98, 2, 255) -- Paradiso
			createRadarArea(-2533, 1358, 537, -143, 107, 21, 169, 255) -- Esplanade North
			createRadarArea(-1996, 1358, 472, -234, 219, 17, 207, 255) -- Esplanade North
			createRadarArea(-1982, 1274, 458, -84, 169, 177, 205, 255) -- Esplanade North
			createRadarArea(-1620, 1176, 40, -98, 136, 175, 37, 255) -- Esplanade East
			createRadarArea(-1580, 1025, 81, -249, 176, 186, 199, 255) -- Esplanade East
			createRadarArea(-1499, 578, 160, -696, 8, 222, 165, 255) -- Esplanade East
			createRadarArea(-1871, 744, 170, -432, 181, 22, 141, 255) -- Financial
			createRadarArea(-2274, 744, 292, -614, 242, 15, 71, 255) -- Calton Heights
			createRadarArea(-2274, 578, 196, -166, 38, 251, 159, 255) -- Chinatown
			createRadarArea(-2533, 578, 259, -390, 75, 236, 94, 255) -- Juniper Hill
			createRadarArea(-2994, 458, 253, -881, 178, 56, 40, 255) -- Palisades
			createRadarArea(-2741, 458, 208, -335, 62, 133, 231, 255) -- Santa Flora
			createRadarArea(-2867, 277, 274, -181, 28, 231, 113, 255) -- City Hall
			createRadarArea(-2533, 458, 204, -120, 21, 200, 44, 255) -- Queens
			createRadarArea(-2593, 54, 182, -404, 249, 198, 222, 255) -- Queens
			createRadarArea(-2411, 373, 158, -85, 54, 117, 1, 255) -- Queens
			createRadarArea(-2329, 458, 336, -120, 192, 30, 104, 255) -- King's
			createRadarArea(-2411, 265, 418, -108, 80, 254, 10, 255) -- King's
			createRadarArea(-2253, 373, 260, -85, 65, 49, 64, 255) -- King's
			createRadarArea(-1794, 249, 552, -329, 40, 159, 226, 255) -- Easter Basin
			createRadarArea(-1794, -50, 295, -199, 240, 50, 199, 255) -- Easter Basin
			createRadarArea(-2270, -324, 476, 102, 165, 168, 232, 255) -- Doherty
			createRadarArea(-2173, -222, 379, -43, 117, 235, 170, 255) -- Doherty
			createRadarArea(-2007, 56, 85, -168, 39, 163, 146, 255) -- Cranberry Station
			createRadarArea(-2411, -222, 238, -43, 108, 241, 138, 255) -- Garcia
			createRadarArea(-2395, -222, 41, 18, 148, 137, 66, 255) -- Garcia
			createRadarArea(-2593, -222, 182, 168, 102, 90, 10, 255) -- Hashbury
			createRadarArea(-2994, 277, 127, -181, 203, 51, 18, 255) -- Ocean Flats
			createRadarArea(-2994, -222, 401, -55, 100, 151, 19, 255) -- Ocean Flats
			createRadarArea(-2994, -430, 163, 208, 51, 40, 165, 255) -- Ocean Flats
			createRadarArea(-2646, -355, 376, 133, 116, 155, 178, 255) -- Avispa Country Club
			createRadarArea(-2831, -430, 185, 208, 113, 175, 102, 255) -- Avispa Country Club
			createRadarArea(-2361, -417, 91, 62, 214, 152, 51, 255) -- Avispa Country Club
			createRadarArea(-2667, -302, 21, 40, 243, 224, 100, 255) -- Avispa Country Club
			createRadarArea(-2470, -355, 200, 37, 252, 48, 229, 255) -- Avispa Country Club
			createRadarArea(-2550, -355, 80, 37, 147, 113, 160, 255) -- Avispa Country Club
			createRadarArea(-2994, -811, 816, 381, 181, 13, 73, 255) -- Missionary Hill
			createRadarArea(-2270, -430, 92, 106, 67, 104, 229, 255) -- Foster Valley
			createRadarArea(-2178, -599, 384, 275, 182, 186, 229, 255) -- Foster Valley
			createRadarArea(-2178, -1115, 384, 516, 101, 102, 231, 255) -- Foster Valley
			createRadarArea(-2178, -1250, 384, 135, 79, 99, 146, 255) -- Foster Valley
			createRadarArea(-1499, -50, 257, -199, 91, 188, 191, 255) -- Easter Bay Airport
			createRadarArea(-1982, 744, 111, -530, 188, 189, 36, 255) -- Downtown
			createRadarArea(-1871, 1176, 251, -98, 52, 70, 174, 255) -- Downtown
			createRadarArea(-1700, 744, 120, -432, 233, 94, 133, 255) -- Downtown
			createRadarArea(-1580, 744, 81, -281, 28, 232, 52, 255) -- Downtown
			createRadarArea(-2078, 578, 579, -166, 133, 167, 112, 255) -- Downtown
			createRadarArea(-1993, 265, 199, -313, 176, 24, 21, 255) -- Downtown

 

In-game, it looks like that:

 

spacer.png

 

Which is of course, bad. Some districts are nicely placed, but some not - it's probably because my calcuations does not work when coords starts/ends with other corner. So my question is, is there a way to determine which corner it starts/ends from map.zon/MTA source code? Or is there other way to implement this, better than trying to do it by hand? Maybe there is a script for that already? I couldn't find any, unfortunately. Thanks!

Link to comment

Okay got it, just my maths, like always XD In case someone need it - you need to absolute the result of X - X1/Y - Y1, not X/Y and X1/Y1 themselves, like I did in my code, cause if there are sectors in other extenses, you'll get too low (or even 0) values of width/height.

Edited by Przemcio
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...