Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
random warping

 
Post new topic   Reply to topic Printable version
 View previous topic  Spawn time bot? Post :: Post Turf and Flag game, awsome if someone ...  View next topic  
Author Message
The Cubbies
Newbie


Joined: Sep 08 2006
Posts: 9
Offline

PostPosted: Tue Sep 26, 2006 2:13 pm    Post subject: random warping Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:37
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Tue Sep 26, 2006 3:46 pm    Post subject: Reply to topic Reply with quote

Code: Show/Hide
if(map[getLinear(x, y)] == vieNoTile) //from the MapTileFormat enum defined in map.h

should do the trick
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:41
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3615
Location: Las Vegas
Offline

PostPosted: Tue Sep 26, 2006 4:22 pm    Post subject: Reply to topic Reply with quote

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.
Code: Show/Hide
x x x
x S x
x x x
Back to top
View users profile Send private message Add User to Ignore List Send email
The Cubbies
Newbie


Joined: Sep 08 2006
Posts: 9
Offline

PostPosted: Tue Sep 26, 2006 4:42 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Tue Sep 26, 2006 4:55 pm    Post subject: Reply to topic Reply with quote

Lemme try this...

Code: Show/Hide
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
View users profile Send private message Add User to Ignore List AIM Address
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:41
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3615
Location: Las Vegas
Offline

PostPosted: Tue Sep 26, 2006 4:57 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 166 page(s) served in previous 5 minutes.

phpBB Created this page in 0.460690 seconds : 30 queries executed (91.6%): GZIP compression disabled