Server Help

Bot Questions - Remember Item List Before Ship Reset

Light Hazard - Tue Jan 03, 2006 7:25 pm
Post subject: Remember Item List Before Ship Reset
Well I am using the great CatID's ctf bot. He was nice enough to show me the source code. As many have noticed, his CTF bot does not support a check on flaggers who warp. I have made a separate plugin to take care of that problem. Now that I have the soure, I added the code from that plugin into the source so it will check right from the CTF plugin.

Now here's my dilemna:
When the flagger drops the flag, whether it's due to a warp or a score, his ship is reset to allow the flag to be dropped. Now the problem lies in the fact that some may want to buy some special items that may cost "creds" in the game.
I wanted to save the item information before *shipreset and then prizing them accordingly if they had that specific item. So far I have failed. I do not understand what I did wrong. So I am attaching the code..

Code: Show/Hide

         if(p->flagCount == 1)
         {
            int brick, decoy, portal, repel, rocket, thor, burst;
            bool stealth, xradar, cloak, shields, supers;

            if (p->flash)
            {
               if(settings->ships[p->ship].CloakStatus == 0)
               {

                  brick = p->brick;
                  decoy = p->decoy;
                  portal = p->portal;
                  repel = p->repel;
                  rocket = p->rocket;
                  stealth = p->stealth ;
                  thor = p->thor ;
                  xradar = p->xradar ;
                  sendPrivate(p, "*shipreset");
                  sendPrivate(p, "*warn Do not warp with the flag!");


                  if (brick)
                  {
                     for (int i = 0; i <= brick; i++)
                     {
                        sendPrivate(p, "*prize #26");
                     }
                  }
                  if (decoy)
                  {
                     for (int i = 0; i <= decoy; i++)
                     {
                        sendPrivate(p, "*prize #23");
                     }
                  }
                  if (portal)
                  {
                     for (int i = 0; i <= portal; i++)
                     {
                        sendPrivate(p, "*prize #28");
                     }
                  }
                  if (repel)
                  {
                     for (int i = 0; i <= repel; i++)
                     {
                        sendPrivate(p, "*prize #21");
                     }
                  }
                  if (rocket)
                  {
                     for (int i = 0; i <= rocket; i++)
                     {
                        sendPrivate(p, "*prize #27");
                     }
                  }
                  if (stealth)
                  {
                     sendPrivate(p, "*prize #4");
                  }
                  if (thor)
                  {
                     for (int i = 0; i <= thor; i++)
                     {
                        sendPrivate(p, "*prize #24");
                     }
                  }
                  if (xradar)
                  {
                     sendPrivate(p, "*prize #6");
                  }
                  String s;
                  s = "*arena ";
                  s += p->name;
                  s += " has dropped the flag!";
                  sendPublic(s);


                  break;
               }
               else
               {
                  Uint16 oldXCoord = get_tag(p, 0);
                  Uint16 oldYCoord = get_tag(p, 1);

                  if (oldXCoord == 0 && oldYCoord == 0)
                  {
                     set_tag(p, 0, p->tile.x);
                     set_tag(p, 1, p->tile.y);
                  }
                  else
                  {
                     Uint16 newXCoord = (Uint16)p->tile.x;
                     Uint16 newYCoord = (Uint16)p->tile.y;
                     
                     Uint32 dist = distance(oldXCoord, oldYCoord, newXCoord, newYCoord);

                     Uint16 oldXCoord = (Uint16)p->tile.x;
                     Uint16 oldYCoord = (Uint16)p->tile.y;

                            if ( dist > 5)
                     {



                        brick = p->brick;
                        decoy = p->decoy;
                        portal = p->portal;
                        repel = p->repel;
                        rocket = p->rocket;
                        stealth = p->stealth ;
                        thor = p->thor ;
                        xradar = p->xradar ;

                        String t;
                        t = "*arena ";
                        t += p->name;
                        t += "<-name ";
                        t += brick;
                        t += "<-brick ";
                        t += portal;
                        t += "<-portal ";
                        t += thor;
                        t += "<-thor ";
                        sendPublic(t);

                        sendPrivate(p, "*shipreset");
                        sendPrivate(p, "*warn Do not warp with the flag!");
                        if (brick)
                        {
                           for (int i = 0; i <= brick; i++)
                           {
                              sendPrivate(p, "*prize #26");

                           }
                        }
                        if (decoy)
                        {
                           for (int i = 0; i <= decoy; i++)
                           {
                              sendPrivate(p, "*prize #23");
                           }
                        }
                        if (portal)
                        {
                           for (int i = 0; i <= portal; i++)
                           {
                              sendPrivate(p, "*prize #28");
                           }
                        }
                        if (repel)
                        {
                           for (int i = 0; i <= repel; i++)
                           {
                              sendPrivate(p, "*prize #21");
                           }
                        }
                        if (rocket)
                        {
                           for (int i = 0; i <= rocket; i++)
                           {
                              sendPrivate(p, "*prize #27");
                           }
                        }
                        if (stealth)
                        {
                           sendPrivate(p, "*prize #4");
                        }
                        if (thor)
                        {
                           for (int i = 0; i <= thor; i++)
                           {
                              sendPrivate(p, "*prize #24");
                           }
                        }
                        if (xradar)
                        {
                           sendPrivate(p, "*prize #6");
                        }

                        String s;
                        s = "*arena ";
                        s += p->name;
                        s += " has dropped the flag!";
                        sendPublic(s);


                        break;
                     }
                  }

D1st0rt - Tue Jan 03, 2006 10:50 pm
Post subject:
I made one of these back last march for use with the CTF plugin. The only thing it doesn't work with is TM_Mer prizes because the playerprize event doesn't catch those.

This should work for what you're looking for, maybe at some point I'll formally publish it to the site
http://d1st0rt.sscentral.com/downloads/reprize.zip
Light Hazard - Wed Jan 04, 2006 12:03 am
Post subject:
Thanks for your help d1st0rt but as I was testing your plugin with the custom ctf plugin, it seems to prize me extra prizes that i just dont have, forexample, if i have a decoy, burst, thrust, warp, and thor, it'd prize me a repel as the only thing available..

What I need to do is record all item information of the flagger before the warp, and then prize the flagger the items back after they warped.
Bak - Wed Jan 04, 2006 12:48 pm
Post subject:
you might want to try spectating the player, waiting until you get a player position packet, and using that information to reprize them.
D1st0rt - Wed Jan 04, 2006 8:12 pm
Post subject:
Oh sorry, I forgot that it only gives greened stuff when you kill a flagger or win a flag game. You can change how many of each item it stores in the ini. The source is there if you want to change it, but bak's idea is probably better.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group