Server Help

Bot Questions - How would I do this?...

Anonymous - Wed Feb 02, 2005 3:52 pm
Post subject: How would I do this?...
I want to make a Golf bot that would spawn powerballs at certain places, and that could also be told to warp people with simple commands like :GolfBot:!1hole Freakman Bob.

I'm sure this is considered simple, but I'm the sort of person who figures stuff out, doesn't just go with MERV or something....

Therefore, any suggestions / code?
Solo Ace - Wed Feb 02, 2005 4:21 pm
Post subject:
You wrote:
I'm sure this is considered simple, but I'm the sort of person who figures stuff out, doesn't just go with MERV or something....


I'm not sure if I understand what you said there, but whatever, I suggest you learn about C++ and MERV (if you don't know about them already, as I said I can't really find out by reading what you said); Some of us would be glad to help.

No idea how to do the ball spawning, I guess it is possible by letting the bot picking up the balls and releasing it somewhere else.

Something to get you started with the warp command (not sure if your idea really is convenient, but whatever, you asked for it). sa_tongue.gif

Code: Show/Hide
void botInfo::gotCommand(Player *p, Command *c)
{
   // Skipping code to improve readability.

   switch (p->access)
   {
   // ...
   case OP_Moderator:
      {
         // Is the used command "[!|.|@]1hole"?
         if (c->check("1hole"))
         {
            // Did the operator use any parameters?
            if (*c->final)
            {
               // Iterate through the playerlist while comparing c->final (which contains the name of the player who needs to be warped)
               // If it's found, send the *warpto (and maybe another message like "Warp'd!") to the player.
               // Otherwise if the player wasn't found, you could send an error message if you want.
            }
            // Error message?
         }
      }
      // ...   
   }
}

Bak - Wed Feb 02, 2005 6:17 pm
Post subject:
no need to iterate through the list solo, you already have the player*

try this:

Code: Show/Hide

void botInfo::gotCommand(Player *p, Command *c)
{
   // Skipping code to improve readability.

   switch (p->access)
   {
   // ...
   case OP_Player:
      {
         // Is the used command "[!|.|@]1hole"?
         if (c->check("1hole"))
         {
                 sendPrivate(p,"*warpto 512 512");
         }
         else if (c->check("2hole"))
         {
                 sendPrivate(p,"*warpto 600 600");
         }
      }
      // ...   
   }
}

Solo Ace - Wed Feb 02, 2005 6:23 pm
Post subject:
No you don't have the Player *, he doesn't want the player (or operator) who used the command to be warped, he wants a certain player in the arena to be warped.

He wrote:
that could also be told to warp people with simple commands like :GolfBot:!1hole Freakman Bob.


But, I may be wrong. icon_confused.gif
Bak - Wed Feb 02, 2005 6:37 pm
Post subject:
you're right... and that's a silly way to do it... but I guess I feel obligated to post the correct code now icon_sad.gif

Code: Show/Hide


void botInfo::gotCommand(Player *p, Command *c)
{
   // Skipping code to improve readability.

   switch (p->access)
   {
   // ...
   case OP_Moderator:
      {
         // Is the used command "[!|.|@]1hole"?
         if (c->check("1hole"))
         {
             bool found = false;

             for (_listnode <Player> *parse = playerlist->head;parse;parse = parse->next)
            {
                 if (strcasecmp(c->final,parse->item->name) == 0)
                 {
                     sendPrivate(parse->item,"*warpto 512 512");
                     found = true;
                     break;
                 }
            }

             if (!found)
                 sendPrivate(p,"Player not found in arena.");
             else
                 sendPrivate(p,"Player found and warped.");
           
         }
      }
      // ...   
   }
}



A more elegent solution would involve checking for substrings of names so you don't have to type the whole name. Hockey Zone has a miniputt bot that does something similar to what it looks like you're developing.
D1st0rt - Wed Feb 02, 2005 11:29 pm
Post subject:
Or you could just set up a TM Baw (?) with warp points set up like in Assault: Overlord from UT GOTY
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group