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
Checking if a player has been warped

 
Post new topic   Reply to topic Printable version
 View previous topic  java and checksums Post :: Post Plugin Help  View next topic  
Author Message
tansey
Novice


Joined: Nov 03 2004
Posts: 53
Offline

PostPosted: Wed Jan 12, 2005 1:20 pm    Post subject: Checking if a player has been warped Reply to topic Reply with quote

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
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: Wed Jan 12, 2005 1:33 pm    Post subject: Reply to topic Reply with quote

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.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
tansey
Novice


Joined: Nov 03 2004
Posts: 53
Offline

PostPosted: Wed Jan 12, 2005 4:14 pm    Post subject: Reply to topic Reply with quote

No, it crashes cause it's checking too much data.

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

thx though =)
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Wed Jan 12, 2005 7:39 pm    Post subject: Reply to topic Reply with quote

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.
_________________
4,691 irradiated haggis!
Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Wed Jan 12, 2005 7:50 pm    Post subject: Reply to topic Reply with quote

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
_________________
Performance is often the art of cheating carefully. - James Gosling
Back to top
View users profile Send private message Add User to Ignore List
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:37
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Wed Jan 12, 2005 8:07 pm    Post subject: Reply to topic Reply with quote

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.
Back to top
View users profile Send private message Add User to Ignore List
50% Packetloss
Server Help Squatter


Age:40
Gender:Gender:Male
Joined: Sep 09 2003
Posts: 561
Location: Santa Clarita, California
Offline

PostPosted: Wed Jan 12, 2005 10:54 pm    Post subject: Reply to topic Reply with quote

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.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
D1st0rt
Miss Directed Wannabe


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

PostPosted: Thu Jan 13, 2005 8:58 pm    Post subject: Reply to topic Reply with quote

In case you people missed it, they already said they fixed it by just checking for p->safety
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
50% Packetloss
Server Help Squatter


Age:40
Gender:Gender:Male
Joined: Sep 09 2003
Posts: 561
Location: Santa Clarita, California
Offline

PostPosted: Fri Jan 14, 2005 12:07 am    Post subject: Reply to topic Reply with quote

Yah, but the rest of the code needs fixing too. It might run fine but its giving me a headache.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:37
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Sat Jan 15, 2005 11:58 am    Post subject: Reply to topic Reply with quote

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
Back to top
View users profile Send private message Add User to Ignore List
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: 363 page(s) served in previous 5 minutes.

phpBB Created this page in 0.448645 seconds : 34 queries executed (92.9%): GZIP compression disabled