 |
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
The Cubbies Newbie
Joined: Sep 08 2006 Posts: 9 Offline
|
Posted: Tue Sep 26, 2006 2:13 pm Post subject: random warping |
 |
|
|
|
I have a function that has the bot warp a player to a random spot on the map. As I have it now, the spot it chooses could have a tile on it. I want to avoid these areas. Is there a way to determine before warping if that spot has a tile? I looked though the map.cpp but couldn't really find what I was looking for. (I'm using Merv). |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:41 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Tue Sep 26, 2006 4:22 pm Post subject: |
 |
|
|
|
Ships are not 16x16, so you need to actually check a box worth around the location you want to warp to, one extra tile in all 8 directions.
|
|
Back to top |
|
 |
The Cubbies Newbie
Joined: Sep 08 2006 Posts: 9 Offline
|
Posted: Tue Sep 26, 2006 4:42 pm Post subject: |
 |
|
|
|
I had already tried Distort's method before posting and I got this error:
spawn.obj : error LNK2001: unresolved external symbol "unsigned long __cdecl getLinear(unsigned long,unsigned long)" (?getLinear@@YAKKK@Z)
I was confused by it, so I posted this topic. I just realized that I needed to #include "..\map.cpp" Sorry for the annoyance. |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Tue Sep 26, 2006 4:55 pm Post subject: |
 |
|
|
|
Lemme try this...
const int mapSize = 1024;
const int clearTiles[] = { 0 /* blank */,
170 /* flag */,
171 /* safe zone */,
172 /* soccer goal */,
173, 174, 175 /* fly over */,
176, 177, 178, 179, 180, 181, 182, 183, 184 /* fly under opaque */,
185, 186, 187, 188, 189, 190 /* fly under transparent */ };
int xTile, yTile;
for(bool foundGoodTile = false; !foundGoodTile;)
{
// pick a random tile not on the border
xTile = 1 + rand() % (mapSize - 2);
yTile = 1 + rand() % (mapSize - 2);
// check if there's any walls near it
for (int dy = -1; dy <= 1; ++dy) for (int dx = -1; dx <= 1; ++dx)
{
int curXTile = xTile + dx;
int curYTile = yTile + dy;
int curIndex = curXTile + mapSize * curYTile;
bool isClear = false;
foundGoodTile = true; // this spot is good unless we prove otherwise
for (unsigned int c = 0; c < sizeof(clearTiles) / sizeof(clearTiles[0]); ++c)
{
if (clearTiles[c] == map[curIndex])
{
isClear = true;
break;
}
}
if (!isClear) // this spot is no good, jump out of both for loops and try a new spot
{
foundGoodTile = false;
goto end_checking_walls;
}
}
end_checking_walls: ;
}
sendPrivate(p, "*warpto " + (String)xTile + " " + (String)yTile); |
_________________ SubSpace Discretion: A Third Generation SubSpace Client
Last edited by Bak on Tue Sep 26, 2006 5:04 pm, edited 2 times in total |
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:41 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Tue Sep 26, 2006 4:57 pm Post subject: |
 |
|
|
|
The Cubbies wrote: | I just realized that I needed to #include "..\map.cpp" |
You shouldn't directly include another source file. The point of having seperate files is that you can compile them into individual object files, and then the linker combinds them. Including it directly just involves your compiler having to recompile the exact same things everytime your file changes. Add the file to your project instead. Once you get up in the tens or hundreds of thousands of lines of code, you'll notice a big difference. |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 166 page(s) served in previous 5 minutes.
|