Server Help

Bot Questions - Yet another newbie question of mine...

Quan Chi2 - Wed Sep 07, 2005 3:37 pm
Post subject: Yet another newbie question of mine...
Can someone tell me how.. or point me in the right direction for this one?

I want to code a few different bots this way..
How do I make my dll turn off/on game mode and actions?

like

Im going to make this bot that gives people a super ship when they enter.. lol just if i get bored one day..

i want to make it so that when i do

.supers on (it turns this mode on, and everyone gets super when they come in)

and

.supers off (no one gets super anymore.. i know that they will still have super, but i'll figure out a way to stop that..)

I pretty much want to make this bot to learn how to turn off and on game modes.. for different games..

Can anyone HELP me on this one? Even a small 3 word tip would be a help.. Im not looking for a full src(a code would be nice of course, but its not needed lol).. I just need some direction...

Thanks in advance..
freakmonger - Wed Sep 07, 2005 3:47 pm
Post subject:
..
Cyan~Fire - Wed Sep 07, 2005 3:48 pm
Post subject:
Make a bunch of setting changes at once using EVENT_ChangeSettings.
Maverick - Wed Sep 07, 2005 4:29 pm
Post subject:
No its more fun to PM everyone *super.... aaand much easier too ! icon_twisted.gif
Purge - Wed Sep 07, 2005 5:21 pm
Post subject:
Maverick wrote:
No its more fun to PM everyone *super.... aaand much easier too ! icon_twisted.gif


They'd have to be sysop or they'll get kicked.
BDwinsAlt - Wed Sep 07, 2005 5:37 pm
Post subject: Re: Yet another newbie question of mine...
Quote:
Can anyone HELP me on this one? Even a small 3 word tip would be a help..


Get A Life.
Maverick - Wed Sep 07, 2005 6:01 pm
Post subject:
Purge+ wrote:
... or they'll get kicked.

hence the evil grin icon_twisted.gif
Quan Chi2 - Wed Sep 07, 2005 8:58 pm
Post subject:
But I want to turn it on and off.. lol
Bak - Wed Sep 07, 2005 8:58 pm
Post subject:
use a boolean variable to keep track if the game is on or not, and then prize based on the value of that variable
Quan Chi2 - Wed Sep 07, 2005 9:25 pm
Post subject:
wtf?
Anonymous - Fri Sep 09, 2005 8:13 am
Post subject:
as bak said you need a boolean which will be toggled TRUE/FALSE when the bot receives a .supers on/off message

then when a player enters the arena you check if the boolean is true, and if it is you prize them super
Solo Ace - Fri Sep 09, 2005 10:12 am
Post subject:
You do need code, obviously. icon_neutral.gif

Well, first what you didn't understand.

Bak wrote:
use a boolean variable to keep track if the game is on or not, and then prize based on the value of that variable

A boolean variable would be a variable (a piece of data of a certain type) which can be set to true or false.
Think of it as a switch.

First make this variable in the botInfo class (spawn.h):

Code: Show/Hide
class botInfo
{
   // Skipping a few lines to improve readability...
   bool give_supers; // <-- Add the variable to this class! Do NOT make another botInfo class.
public:
   botInfo(CALL_HANDLE given)
   {


Now you can use this "switch" to turn things on and off.
It doesn't do much yet though, we have to make something to turn the switch on or off.
Solo Ace - Fri Sep 09, 2005 10:14 am
Post subject:
Do you want our switch to be on or off by default?

I'm not sure if you have to set it to false with your compiler, let's just enable it by default:

In the same class (under "botInfo(CALL_HANDLE given)", which is what we call the "constructor" of the class) you add a line like:

Code: Show/Hide
class botInfo
{
   // Skipping a few lines to improve readability...
   bool give_supers;
public:
   botInfo(CALL_HANDLE given)
   {
      give_supers = true; // <-- This will enable our feature by default.

Solo Ace - Fri Sep 09, 2005 10:14 am
Post subject:
Now we can implement a command to turn give_supers on or off, in command.cpp (make sure to put this command in the right operator code block!).

Code: Show/Hide
         if (c->check("supers"))
         {
            if (c->checkParam("on"))
            {
               if (give_supers)
                  sendPrivate(p, "Prizing super was enabled already.");
               else
               {
                  give_supers = true;
                  sendPrivate(p, "Prizing super is now enabled.");   
               }
            }
            else if (c->checkParam("off"))
            {
               if (give_supers)
               {
                  give_supers = false;
                  sendPrivate(p, "Prizing super is now disabled.");
               }
               else
                  sendPrivate(p, "Prizing super was disabled already.");
            }
            else
            {
               // No parameter for the supers command was used, we could make the plugin
               // give the current status of the prizing.
   
               String s = "Prizing super is currently ";
               
               if (give_supers)
                  s += "enabled.";
               else
                  s += "disabled.";
               
               sendPrivate(p, s);
   
               // You could, of course, show the command syntax help.
               //sendPrivate(, "Please specify a parameter for the !supers command: !supers [on|off].");
            }
         }

Solo Ace - Fri Sep 09, 2005 10:15 am
Post subject:
Or maybe you'd prefer something like this (with a seperate status command parameter):

Code: Show/Hide
            if (c->check("supers"))
            {
               if (c->checkParam("on"))
               {
                  if (give_supers)
                     sendPrivate(p, "Prizing super was enabled already.");
                  else
                  {
                     give_supers = true;
                     sendPrivate(p, "Prizing super is now enabled..");   
                  }
               }
               else if (c->checkParam("off"))
               {
                  if (give_supers)
                  {
                     give_supers = false;
                     sendPrivate(p, "Prizing super is now disabled.");
                  }
                  else
                     sendPrivate(p, "Prizing super was disabled already.");
               }
               else if (c->checkParam("status"))
               {
                  // Show status of super prizing.
                  String s = "Prizing super is currently ";

                  if (give_supers)
                     s += "enabled.";
                  else
                     s += "disabled.";

                  sendPrivate(p, s);
               }
               else
               {
                  sendPrivate(p, "Please specify a parameter for the !supers command: !supers [on|off|status].");
               }
            }

Solo Ace - Fri Sep 09, 2005 10:16 am
Post subject:
Now we have to make sure the bot will actually prize super to players if give_supers is set to true.

Which is done like this (in spawn.cpp):

Code: Show/Hide
   case EVENT_PlayerShip:
      {
         Player *p = (Player*)event.p[0];
         Uint16 oldship = (Uint16)(Uint32)event.p[1];
         Uint16 oldteam = (Uint16)(Uint32)event.p[2];
         
         // Are we giving super? If so, send a *prize #17 (super).
         if (give_supers)
            sendPrivate(p, "*prize #17");
      }
      break;

Solo Ace - Fri Sep 09, 2005 10:26 am
Post subject:
If you'd want to want to remove everyone's super, you'd just do this at the part where super was disabled.

Code: Show/Hide
   // Iterate through the playerlist and remove everyone's super (*prize #-17).
   
   _listnode <Player> *parse = playerlist->head;

   while (parse)
   {
      Player *p = parse->item;
      
      if (p->ship != SHIP_Spectator)
         sendPrivate(p, "*prize #-17");

      parse = parse->next;
   }


This will send *prize #-17 to everyone who's currently in the arena (in a ship).

Maybe checking if a player is really in a ship (not spectator) is required when prizing super too.
Dr Brain - Fri Sep 09, 2005 10:50 am
Post subject:
6 posts in a row. Some kind of a record?
Mine GO BOOM - Fri Sep 09, 2005 11:36 am
Post subject:
Dr Brain wrote:
6 posts in a row. Some kind of a record?

Actually, I like the way he laid it out. Making them into new posts divides the topics he covers in each post very well.
D1st0rt - Fri Sep 09, 2005 12:48 pm
Post subject:
I think it's still a record, even though its done in good taste.
Chambahs - Fri Sep 09, 2005 1:59 pm
Post subject:
solo, why dont you just write the whole damn thing for him?
LearJett+ - Fri Sep 09, 2005 2:24 pm
Post subject:
Wow, people are very helpful on here icon_eek.gif
Solo Ace - Fri Sep 09, 2005 2:37 pm
Post subject:
He wants to learn, obviously. You don't learn much by getting completed work in your hands.

Also, I had it split up because multiple code boxes were messing my posts up.

The record would be MGB's "The Leper's Colony", and well, maybe there are other threads where some spammer has created more posts in one row.

Why are you all whining about what I just wrote? You are acting like a bunch of sheep. It's not the point how many posts I took for it.
You don't buy a very expensive TV and then put a bag on it. You don't buy a very expensive horse and then say "bah, stupid horse" as soon as you get it. sa_tongue.gif
You don't read a decent article and then whine because it took a few pages.
You wouldn't whine about the way my decent guide was posted if you would respect the effort that was put into it.
Spoiled brats, always having something to complain.
Some people on this planet don't have much more than shoes and the ground they stand on, and you complain about 6 posts?

Sorry, I'll get back to normal mode. sa_tongue.gif
Dr Brain - Fri Sep 09, 2005 2:39 pm
Post subject:
Solo Ace wrote:
Also, I had it split up because multiple code boxes were messing my posts up.


Ah. That explains it.

Also I was not complaining. Just commenting.
Solo Ace - Fri Sep 09, 2005 2:43 pm
Post subject:
I was kidding, you know that.
Bak - Fri Sep 09, 2005 5:49 pm
Post subject:
excellent tutorial, and excellent code formatting. :)

Quan, there's a tutorial for MervBot that can teach you to do a bunch of neat things at http://bots.sscentral.com/mav/files/MERVbot%20tutorial.html . Read through that and try some things out; it's well worth the time if you're serious about making plugins.
Quan Chi2 - Fri Sep 09, 2005 8:08 pm
Post subject:
Thanks biggrin.gif
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group