Server Help

Bot Questions - Checking if a player has been warped

tansey - Wed Jan 12, 2005 1:20 pm
Post subject: Checking if a player has been warped
I'm writing a bot for a free-for-all, elim style event. Basically, all players enter and are spawned in the center of the map(i.e. the safe zone) which is boxed in. There are various boxes (20+) which the players can vote on to play. Each box has a safety zone of its own that players start in. Once a box has been picked, the bot warps them to the box's safety zone and they play.

There are 4 ways to be eliminated from the game: death, spec, exit arena, or be warped back to safe. I have it all working except for the warping back to safe part. What I've tried is this:

Code: Show/Hide
case EVENT_PlayerMove:
      {
         Player *p = (Player*)event.p[0];
         if( GetTickCount() % 6 == 0 && pb->getState() == STATE_runEvent && isStillIn((String)p->name))
         {
            
            if( (p->pos.y / 16) > 488 && (p->pos.x / 16) < 535 && (p->pos.y / 16) > 480 && (p->pos.y / 16) < 535 )
            {
               pilots.unlist(p);
               playerCount--;
            }
         }
      }


Using this code will crash the bot. Pretty straight-forward code I thought: GetTickCount() % 6 is there so that the bot doesn't check too frequently, then it makes sure the bot is currently running the event, then it checks that the player has not yet been eliminated. I broke it up into 2 if's for clarity. I tried using p->tile.x and .y but it still crashes.

Is there any other way to check if a player warps? Or how about if a player is in a safe zone? Both would work for my case.

Thanks,
--tansey
Bak - Wed Jan 12, 2005 1:33 pm
Post subject:
I'd take out the getTickCount(), but that's just me.

There are two possibilities that could crash it. Either pilots (which looks like some kind of collection) isn't initialized properly (is there an init function?), or pb is never assigned a correct value. Where do you initialize these variables? You could printf pb to check if it's an actual pointer or 0.
tansey - Wed Jan 12, 2005 4:14 pm
Post subject:
No, it crashes cause it's checking too much data.

I fixed the problem anyway...forgot about p->safety lol

thx though =)
Mr Ekted - Wed Jan 12, 2005 7:39 pm
Post subject:
Do not assume GetTickCount() has a granularity of 1ms. If you put it in a tight loop and dump values, you will typically get results like: 0 10 20 31 41 52 62 ... So (x % 6) == 0 won't be as regular as you'd expect. Use a counter or some kind of time delta.
CypherJF - Wed Jan 12, 2005 7:50 pm
Post subject:
Yeah my one friend found that out when he was designing a game; i guess different processor's gave him different tick counts or something. I thought it was slightly funny .. enough to get a chuckle icon_smile.gif
Solo Ace - Wed Jan 12, 2005 8:07 pm
Post subject:
I think you should learn how to debug your plugins for MERVbot.
Not sure if you have MS VC++, but this is how you debug your MERV plugins:

  1. Open up the MERVbot's core project and rebuild the MERVbot in Debug mode;
  2. In the MERV's settings make sure the plugin you want to debug gets loaded (to do this you'll have to make sure the plugin you wish to debug is in the project directory of the loaded MERV, of course);
  3. In Windows, drag & drop the code file (spawn.cpp) you wish to debug to the MERVBot project into the IDE;
  4. Place breakpoints in the code you wish to debug, the debugger will pause execution of the program there when it reaches the code;
  5. Run the MERV from the project, attempt to get the code where you put your breakpoint(s) executed (in your case, generate the event EVENT_PlayerMove, by moving your ship?).

After doing this you can see values of variables (by adding a watch or by just hovering over it with your mouse), and you can step through the code using F10 (step over) and F11 (step into).
By doing this you can see which, how and when the code is being executed.

This information may not be useful to you, but maybe someone else can use it.
50% Packetloss - Wed Jan 12, 2005 10:54 pm
Post subject:
Computers are fast, you arent checking too much data.

1. Get rid of the tickcount, Ekted is competely correct.
2. If you want tile locations do p->tile.x and p->tile.y, the core runs a function that automatically updates the pos and tile vectors.
3. If you are using one of catid's linklist classes for your "pilots" variable then you dont need a playerCount variable. Just do pilots->total and that will show you how many items are on the list.
4. Do not use catid's String class, I guess you could use it for long strings or such but not to pass variables to functions.
5. Read what Solo Ace said, the debug features in VC++ has saved me a lot of time when finding small error. Try writting a powerbot dll and debugging it remotely, its not fun.
D1st0rt - Thu Jan 13, 2005 8:58 pm
Post subject:
In case you people missed it, they already said they fixed it by just checking for p->safety
50% Packetloss - Fri Jan 14, 2005 12:07 am
Post subject:
Yah, but the rest of the code needs fixing too. It might run fine but its giving me a headache.
Solo Ace - Sat Jan 15, 2005 11:58 am
Post subject:
Well sure they fixed it, but I said "This information may not be useful to you", because maybe he doesn't use VC++ (but someone else could still use it) or, if he does, he'd might be able to use it to fix future problems (so he doesn't have to "guess" anymore). sa_tongue.gif
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group