Server Help

Bot Questions - Moving Flags

Cyan~Fire - Mon Nov 03, 2003 6:07 pm
Post subject: Moving Flags
OK, I'm trying to make the bot just grab a flag and put it somewhere. I know I gotta use EVENT_GrabFlag, but what next? I was looking for a move bot event or something, but there isn't one. Can someone guide me on how to do this (or just send me the CTF source icon_wink.gif)?

I'm probably just missing something easy. icon_razz.gif
ExplodyThingy - Mon Nov 03, 2003 6:28 pm
Post subject:
Code: Show/Hide

bool grabbing; //in ship
int team; //specfreq

void botInfo::CheckFlags()
{
   _listnode <Flag> *parse_1 = flaglist->head;
   while (parse_1)
   {
      Flag *flag = parse_1->item;
      if (matrix.BadPlayerGrid(flag->x, flag->y))
      {
         String s;
         s += "Taking flag at ";
         s += flag->x;
         s += ", ";
         s += flag->y;
         tell(makeEcho(s));
         IllegalFlag(flag);
      }
      parse_1 = parse_1->next;
   }

   if(grabbing)
      dropFlags();
}
void botInfo::IllegalFlag(Flag *flag)
{
   if (!grabbing)
   {
      tell(makeShip(SHIP_Warbird));
      grabbing = true;

      tell(makeFollowing(false));
      tell(makeFlying(true));
      String s = "*setfreq ";
      s += team;
      sendPrivate(me, s);
   }
   tell(makeGrabFlag(flag->ident));
}
void botInfo::dropFlags()
{
   grabbing = false;
   me->move(512 * 16, 512 * 16);
   tell(makeSendPosition(true));
   tell(makeShip(SHIP_Spectator));

   tell(makeFollowing(true));
   tell(makeFlying(false));
}


if (matrix.BadPlayerGrid(flag->x, flag->y))
is the boolean check for flag location. You can simply replace it with "if(BadFlag(parse_1->item))" and make a "bool botInfo::BadFlag(Flag *f)" function to check if "f" is in your bad region.
Cyan~Fire - Mon Nov 03, 2003 6:37 pm
Post subject:
Lol, wow. All I needed was the me->move part, but that'll save me a lot of time. Thanks a lot!
k0zy - Tue Nov 04, 2003 12:43 am
Post subject:
Tell me if it worked...
I tried to code such a bot once, but i couldn't get it to move more than 6 flags at a time.

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
Dustpuppy - Tue Nov 04, 2003 8:16 am
Post subject:
That's catid's flagmover. It only moves one flag at a time though IIRC.
Cyan~Fire - Tue Nov 04, 2003 7:42 pm
Post subject:
Actually, Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole...., I only need it to move 1 flag at a time. Sorry.
Cyan~Fire - Wed Nov 05, 2003 10:22 pm
Post subject:
OK, I got everything done, thanks for your help. Except, the bot doesn't spec after it moves the flag.

Code: Show/Hide
void botInfo::change_flag(int ident, int team)
{
   tell(makeShip(SHIP_Warbird));
   tell(makeTeam(team));
   tell(makeFollowing(false));
   tell(makeGrabFlag(ident));
   tell(makeFlying(true));
   me->move(setts.base_x * 16, setts.base_y[team] * 16);
   tell(makeSendPosition(true));
   tell(makeDropFlags());
   tell(makeShip(SHIP_Spectator));
   tell(makeFlying(false));
   tell(makeFollowing(true));
}

The bot will do another change_flag, so it is completing, but it just doesn't spec. I'm probably making a stupid mistake, but usually other people catch em more easily. icon_wink.gif

Thanks,
Cyan
Dustpuppy - Thu Nov 06, 2003 6:23 am
Post subject:
You've moved some of the tell() statements (specifically makeFlying() and makeFollowing()). Make sure they are in the same places as in the code 'splody posted.
Cyan~Fire - Thu Nov 06, 2003 6:14 pm
Post subject:
Thanks, but that's not the problem. (I tried messing with the order before.) This is very odd...
Anonymous - Fri Nov 07, 2003 7:51 am
Post subject:
Order, definately wrong.
switch makeFlying and makeGrabFlag, remove makeDropFlags
Cyan~Fire - Fri Nov 07, 2003 4:48 pm
Post subject:
OK, yeah, I changed that, but it does the same thing.
First of all, I need DropFlags because I want the bot to drop owned flags not neuted ones.
And Second, everything is working fine except spectating. The bot drops the flags owned, in the right place, and even spectates just for like a millisecond (The Spectator sign flashes for a sec), and then goes to 512,512 and stays there.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group