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
Double check still no effect.

 
Post new topic   Reply to topic Printable version
 View previous topic  Plugin Problems Post :: Post Error in extracting plugins  View next topic  
Author Message
Guest



Offline

PostPosted: Sat May 14, 2005 3:13 pm    Post subject: Double check still no effect. Reply to topic Reply with quote

Hey there,

I made a bot, and if a player comes in a "box" it will be warped to a turretpoint. I made a feature that if there is already a person at the turretpoint, the next person entering the warp box will be warped to the alternative turretpoint. Though the bot doesn't agree with me and keeps warping him to the same turretpoint. Who wants to help me?

-Arctica

PS: the code:

Quote:
case EVENT_Tick:
{
for (int i = 0; i < 4; ++i)
--countdown[i];
Player *p = (Player*)event.p[0];
turrpoint1=0;
_listnode <Player> *parse2 = playerlist->head;

while(parse)
{
Player *p = parse2->item;

if(level == 0)
{
if(p->tile.x >= 89 && p->tile.x <= 91 && p->tile.y >= 18 && p->tile.y <= 20)
{
turpoint1++;
}
}
parse2 = parse->next;
}


Then later:

case EVENT_PlayerMove:
{
Player *p = (Player*)event.p[0];
if(p->tile.x >= 502 && p->tile.x <= 503 && p->tile.y >= 512 && p->tile.y <= 513)
{
if(level == 0 && turpoint1 == 0)
{
sendPrivate(p, "*warpto 90 19");
sendPrivate(p, "You are warped to turretpoint 1.");
}
}
if(p->tile.x >= 502 && p->tile.x <= 503 && p->tile.y >= 512 && p->tile.y <= 513)
{
if(level == 0 && turpoint1 != 0)
{
sendPrivate(p, "*warpto 90 24");
sendPrivate(p, "Turrentpoint occupied, alternative warping..");
}
Back to top
Guest



Offline

PostPosted: Sat May 14, 2005 3:16 pm    Post subject: Reply to topic Reply with quote

lol ops, used quote instead of code ;/
Back to top
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 May 14, 2005 3:50 pm    Post subject: Reply to topic Reply with quote

I find your code pretty disturbing, but whatever, I'm not in the mood to fix that for you.

Maybe a quote from a post I made in some thread can help you.

Solo Ace wrote:
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.


Quoted from this thread.
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sat May 14, 2005 3:52 pm    Post subject: Reply to topic Reply with quote

Code: Show/Hide
case EVENT_Tick:
      {
         for (int i = 0; i < 4; ++i)
            --countdown[i];
         Player *p = (Player*)event.p[0];
                                                turrpoint1=0;
                                               _listnode <Player> *parse2 = playerlist->head;

         while(parse)
         {
            Player *p = parse2->item;

            if(level == 0)
            {
               if(p->tile.x >= 89 && p->tile.x <= 91 && p->tile.y >= 18 && p->tile.y <= 20)
               {
                  turpoint1++;
               }
            }
                                                                parse2 = parse->next;
         }


Then later:

case EVENT_PlayerMove:
      {
         Player *p = (Player*)event.p[0];
         if(p->tile.x >= 502 && p->tile.x <= 503 && p->tile.y >= 512 && p->tile.y <= 513)
         {
            if(level == 0 && turpoint1 == 0)
            {
               sendPrivate(p, "*warpto 90 19");
               sendPrivate(p, "You are warped to turretpoint 1.");
            }
         }
         if(p->tile.x >= 502 && p->tile.x <= 503 && p->tile.y >= 512 && p->tile.y <= 513)
         {
            if(level == 0 && turpoint1 != 0)
            {
               sendPrivate(p, "*warpto 90 24");
               sendPrivate(p, "Turrentpoint occupied, alternative warping..");
            }

That is so much easier to read, you shoulda re-posted.

First of all, the two if statements at the bottom (if(p->tile.x >= 502 && p->tile.x <= 503 && p->tile.y >= 512 && p->tile.y <= 513)) should be combined, as they both have the same condition.

Second, can people get to the turretpoint other than by warping? If not, you should just have a boolean that you set when you warp them, and then check that boolean instead of cycling through all the players. Even if they can get there otherwise, don't do it every tick. That's far too slow and also there will be some players that haven't moved so it will be pointless to check them. Check to see if anyone's at the turretpoint on EVENT_PlayerMove.

And this is just my preference, but I think it's easier for the coder and for people reading the code just to make a sort of macro, something like:
Code: Show/Hide
#define LIMIT(value, left, right) \
   (value >= left && value <= left)


It will make the code much easier to read.
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
The Arctica
Newbie


Gender:Gender:Male
Joined: Dec 04 2004
Posts: 13
Offline

PostPosted: Sat May 14, 2005 4:10 pm    Post subject: Reply to topic Reply with quote

sorry bout the code, and that guest was me, anyways, it can leave also and then the bool will be still at true/false so it wouldnt change.
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: 14 page(s) served in previous 5 minutes.

phpBB Created this page in 0.515769 seconds : 29 queries executed (94.5%): GZIP compression disabled