PDA

View Full Version : Getting map size


Shaman
04-27-2008, 14:00
How can I get a map's width, height and depth? I am making a plugin that must know map's size, because it shouldn't treat fy_pool_day and cs_militia the same way.

Also corner origins wil also be useful so I can loop all points in the map.

grimvh2
04-27-2008, 15:02
Hmmm , I make maps but I dont know if this would be easy .

Exolent[jNr]
04-27-2008, 15:03
I suggest you just create a non-existent box with coordinates saved to a file.
Then, you can just check if player is inside the box.

Shaman
04-27-2008, 15:15
Can't I get map's width, height and depth? Or some origins maybe.

BOYSplayCS
04-27-2008, 16:09
Can't I get map's width, height and depth? Or some origins maybe.

I really don't know. I'd do what X stated.

Maybe v3x or VEN would know.

|PJ| Shorty
04-27-2008, 16:39
http://www.amxmodx.org/funcwiki.php?go=func&id=1034
http://www.amxmodx.org/funcwiki.php?go=func&id=91

Shaman
04-27-2008, 17:12
Not that size. Maybe I should edit the first post.

v3x
04-27-2008, 17:19
I really don't know. I'd do what X stated.

Maybe v3x or VEN would know.
I've been trying to think of a way but nothing is coming up :|

Shaman
04-27-2008, 18:02
If there is a way to check if a point is in the map, then I can code a function that can find bounds of the map.

BOYSplayCS
04-27-2008, 18:33
coordinates?

grimvh2
04-28-2008, 11:24
I think its not possible , if you can make maps you normally think the same about it , but I am not a skilled scripter ofcoarse .

VEN
04-29-2008, 14:05
There are no good/direct ways. Traceline method isn't 100% proof, requires analysis and checking for different mapping methods.

Alka
04-29-2008, 14:35
Hmm...i thought at traceline, from center of map, trace 6 lines (-+X,-+Y,-+Z) and ignore the walls hited, until the origin is still in map(???), then sum up the distances, but dunno how to do that entirely.

I would like to see a way to do that no matter if isn't 100% accurate...

Orangutanz
04-29-2008, 18:49
Hmm...i thought at traceline, from center of map, trace 6 lines (-+X,-+Y,-+Z) and ignore the walls hited, until the origin is still in map(???), then sum up the distances, but dunno how to do that entirely.

I would like to see a way to do that no matter if isn't 100% accurate...
How can you determine the center of the map :mrgreen:

I've just done a dump on index 0, and there is no information regarding:
origin along with min/max
absmin/absmax

The above are crucial for finding out the size of objects.


It's impossible (using pawn), unless you can decompile the BSP file in realtime then filter out all the coordinates within the MAP file also in realtime, just to get the size of the map. Too much hassle, good luck in finding someone to do this for you :mrgreen:

If you are serious then I'd suggest, decompiling the BSP files and getting the coordinates you require and storing this information into your script. Ok its not dynamic as you want it to be, but you can get the most popular maps done.

Out of curiousity what do you want this for, we might be able to suggest alternative methods? Can't believe no one has asked you this question!

Orangutanz
04-29-2008, 19:17
Just had a smoke...

What we do know is this:
Absolute minimum coordinates: -4096, -4096, -4096
Absolute maximum coordinates: 4096, 4096, 4096
Central origin: 0, 0, 0 (note map maynot be located here)

What you'd need to do then, is search through all of those coordinates using:
engfunc( EngFunc_PointContents, ORIGIN ) and see if it returns < CONTENTS_EMPTY
If it does then you need to shuffle the x y & z to see if the next set of coordinates returns CONTENTS_EMPTY.

What you are looking for is capturing the absmin and the absmax of the map, doing this in realtime is going to lag the hell out of the server since it's a lot of calculations so it would be advisable storing this data once found.

Shaman
05-12-2008, 15:34
I'm not trying to find the space that map takes. There is a box around all maps and I must get that box's bound coordinates.

I am trying to find random points that players can reach. First I've made a script that randomly walks through the map and pick random points. It wasn't doing what I need, because sometimes it was coming back to where it came from.

Now I am trying to grid the whole map and find intersections of the grid lines and use them after checking if it can be reached by a player.

I am trying to spawn things like runes in RuneMod and players in CSDM, but I need a more intelligent system that can spawn things in every place that a player can go. The system must include roofs, tunnels, places that can be reached by jumping over boxes, ducking into vents or by opening a door.

Maybe we can code a universal spawn point generation API that can be used in CSDM, RuneMod, the plugin I am going to make and other plugins.

Maybe a normal Windows application can decompile the map, generate spawn points and output a file that can be used in plugins.

[ --<-@ ] Black Rose
05-12-2008, 15:59
Or just spawn stuff and drop it to the ground, if it still has floating flag or something delete it and make a new.

Shaman
05-13-2008, 10:09
Black Rose;624936']Or just spawn stuff and drop it to the ground, if it still has floating flag or something delete it and make a new.
I want to make something "intelligent".

[ --<-@ ] Black Rose
05-13-2008, 12:24
I want to make something "intelligent".

Ye, I don't think there's a better way.

You could add some checks to see if a player would fit in the spot it was placed.

hlstriker
05-14-2008, 04:44
EDIT: Just saw your most recent post and it doesn't look like this is what you wanted, but you can use this as a base to do what you want (it would take a lot of time to get it perfect, and a lot of processing).

I threw this plugin together going off of some of the information Orangutanz posted.

I didn't do any testing to check if it is correct or not, I'll leave that up to you.

Note: Changing the GRID_SIZE will change how accurate it is, but in return it will change how fast it processes.

Note 2: Yes it's sloppy... feel free to optimize it.

How to use:
1) Compile plugin.
2) Add plugin to server.
3) Type "mapsize" in server console.
4) Read the output (in the server console).

Not sure if this is what you wanted or not, I'm tired :)

#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Map Size"
#define VERSION "1.0"
#define AUTHOR "hlstriker"

#define MAP_MIN -4096
#define MAP_MAX 4096

// Smallest size is most accurate, BUT takes longer to process
//#define GRID_SIZE 1
//#define GRID_SIZE 2
#define GRID_SIZE 4
//#define GRID_SIZE 8
//#define GRID_SIZE 16
//#define GRID_SIZE 32

new Float:g_flOrigin[3];
new g_iMin_X, g_iMax_X;
new g_iMin_Y = -5000, g_iMax_Y;
new g_iMin_Z, g_iMax_Z;

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_srvcmd("mapsize", "get_map_size");
}

public get_map_size()
{
new iCurrentY = MAP_MIN;
new iTemp;

server_print("Gathering map size information, please be patient.");

while(iCurrentY <= MAP_MAX)
{
// Get minimum X origin
iTemp = check_min_x(iCurrentY);
if(iTemp < g_iMin_X)
g_iMin_X = iTemp;

// Get maximum X origin
iTemp = check_max_x(iCurrentY);
if(iTemp > g_iMax_X)
g_iMax_X = iTemp;

// Get minimum Z origin
iTemp = check_min_z(iCurrentY);
if(iTemp < g_iMin_Z)
g_iMin_Z = iTemp;

// Get maximum Z origin
iTemp = check_max_z(iCurrentY);
if(iTemp > g_iMax_Z)
g_iMax_Z = iTemp;

iCurrentY += GRID_SIZE;
}

server_print("[Min X = %i] [Max X = %i]", g_iMin_X, g_iMax_X);
server_print("[Min Y = %i] [Max Y = %i]", g_iMin_Y, g_iMax_Y);
server_print("[Min Z = %i] [Max Z = %i]", g_iMin_Z, g_iMax_Z);
}

// Start X coords
check_min_x(const iCurrentY)
{
// Return the minimum X origin that isn't empty
static iContents, iCurrentX, bool:mHit, bool:mEmpty;
mEmpty = false;
mHit = false;
iContents = 0;
iCurrentX = MAP_MIN;

g_flOrigin[1] = 0.0; // Z
g_flOrigin[2] = float(iCurrentY); // Y

while(iCurrentX <= MAP_MAX)
{
g_flOrigin[0] = float(iCurrentX); // X

iContents = engfunc(EngFunc_PointContents, g_flOrigin);
if(iContents != -1 && mEmpty)
{
mHit = true;
break;
}
else if(iContents == -1)
mEmpty = true;

iCurrentX += GRID_SIZE;
}

// Check the Y origin
if(mHit)
{
if(g_iMin_Y < MAP_MIN)
g_iMin_Y = iCurrentY;
else
g_iMax_Y = iCurrentY;
}

return iCurrentX;
}

check_max_x(const iCurrentY)
{
// Return the maximum X origin that isn't empty
static iContents, iCurrentX, bool:mHit, bool:mEmpty;
mEmpty = false;
mHit = false;
iContents = 0;
iCurrentX = MAP_MAX;

g_flOrigin[1] = 0.0; // Z
g_flOrigin[2] = float(iCurrentY); // Y

while(iCurrentX >= MAP_MIN)
{
g_flOrigin[0] = float(iCurrentX); // X

iContents = engfunc(EngFunc_PointContents, g_flOrigin);
if(iContents != -1 && mEmpty)
{
mHit = true;
break;
}
else if(iContents == -1)
mEmpty = true;

iCurrentX -= GRID_SIZE;
}

// Check the Y origin
if(mHit)
{
if(g_iMin_Y < MAP_MIN)
g_iMin_Y = iCurrentY;
else
g_iMax_Y = iCurrentY;
}

return iCurrentX;
}

// Start Z coords
check_min_z(const iCurrentY)
{
// Return the minimum Z origin that isn't empty
static iContents, iCurrentZ, bool:mHit, bool:mEmpty;
mEmpty = false;
mHit = false;
iContents = 0;
iCurrentZ = MAP_MIN;

g_flOrigin[0] = 0.0; // X
g_flOrigin[2] = float(iCurrentY); // Y

while(iCurrentZ <= MAP_MAX)
{
g_flOrigin[1] = float(iCurrentZ); // Z

iContents = engfunc(EngFunc_PointContents, g_flOrigin);
if(iContents != -1 && mEmpty)
{
mHit = true;
break;
}
else if(iContents == -1)
mEmpty = true;

iCurrentZ += GRID_SIZE;
}

// Check the Y origin
if(mHit)
{
if(g_iMin_Y < MAP_MIN)
g_iMin_Y = iCurrentY;
else
g_iMax_Y = iCurrentY;
}

return iCurrentZ;
}

check_max_z(const iCurrentY)
{
// Return the maximum Z origin that isn't empty
static iContents, iCurrentZ, bool:mHit, bool:mEmpty;
mEmpty = false;
mHit = false;
iContents = 0;
iCurrentZ = MAP_MAX;

g_flOrigin[0] = 0.0; // X
g_flOrigin[2] = float(iCurrentY); // Y

while(iCurrentZ >= MAP_MIN)
{
g_flOrigin[1] = float(iCurrentZ); // Z

iContents = engfunc(EngFunc_PointContents, g_flOrigin);
if(iContents != -1 && mEmpty)
{
mHit = true;
break;
}
else if(iContents == -1)
mEmpty = true;

iCurrentZ -= GRID_SIZE;
}

// Check the Y origin
if(mHit)
{
if(g_iMin_Y < MAP_MIN)
g_iMin_Y = iCurrentY;
else
g_iMax_Y = iCurrentY;
}

return iCurrentZ;
}

minimiller
08-23-2008, 18:51
Dude!
Does this get the max co-ords of each map?
I need this for a plugin im making, but i need to know if this works
I got work 2moro morning, so i cant test yet
If any1 can test this and confirm that it works, i would +k you and hlstriker till the day i die