.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Releases, Installers, Docs & Coding (http://forums.bots-united.com/forumdisplay.php?f=48)
-   -   doesn't this prevent em buying grenades? (http://forums.bots-united.com/showthread.php?t=1783)

bluebyte 26-05-2004 22:32

doesn't this prevent them from buying grenades?
 
I have R2.1 of sPlOrYgOn's dll. In bot.cpp we have (between lines 3346 and 3414) :
Code:


// Needs an Item ?
else if (pBot->iBuyCount < 7)
{
        // Care first about buying Armor
        if (pBot->iBuyCount == 4)
        {
                if ((pBot->pEdict->v.armorvalue == 0) && (pBot->bot_money > 650))
                {
                        if (pBot->bot_money > 1000)
                        {
                        if (g_bIsOldCS15)
                                FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 2\n");
                        else
                                FakeClientCommand (pEdict, "vesthelm\n");
                        }
                        else
                        {
                        if (g_bIsOldCS15)
                                FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 1\n");
                        else
                                FakeClientCommand (pEdict, "vest\n");
                        }
                }
        }
        // Buy Grenade or Defuse Kit
        else
        {
                if (pBot->bot_money > 300)
                {
                        // If Defusion Map & Counter buy Defusion Kit
                        if ((g_iMapType & MAP_DE) && (pBot->bot_team == TEAM_CS_COUNTER) && !pBot->b_has_defuse_kit)
                        {
                        if (g_bIsOldCS15)
                                FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 6\n");
                        else
                                FakeClientCommand (pEdict, "defuser\n");
                        }
                        // Else buy Grenade
                        else
                        {
                        int iGrenadeType = RANDOM_LONG (1, 100);
                        // Focus on HE Grenades
                        if (iGrenadeType < 70)
                        {
                                if (g_bIsOldCS15)
                                        FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 4\n");
                                else
                                        FakeClientCommand (pEdict, "hegren\n");
                        }
                        else if (iGrenadeType < 90)
                        {
                                if (g_bIsOldCS15)
                                        FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 5\n");
                                else
                                        FakeClientCommand (pEdict, "sgren\n");
                        }
                        else if (iGrenadeType < 100)
                        {
                                if (g_bIsOldCS15)
                                        FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 3\n");
                                else
                                        FakeClientCommand (pEdict, "flash\n");
                        }
                        }
                }
        }

If I not wrong, the bot is allowed to buy a grenade only if it doesn't buy an armor or a defuse kit. Shouldn't we remove these elses:
Code:

        // Buy Grenade or Defuse Kit
        else
        {

and
Code:


                        // Else buy Grenade
                        else
                        {

and then place the block

Code:


 
                        int iGrenadeType = RANDOM_LONG (1, 100);
                        // Focus on HE Grenades
                        if (iGrenadeType < 70)
                        {
                                if (g_bIsOldCS15)
                                        FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 4\n");
                                else
                                        FakeClientCommand (pEdict, "hegren\n");
                        }
                        else if (iGrenadeType < 90)
                        {
                                if (g_bIsOldCS15)
                                        FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 5\n");
                                else
                                        FakeClientCommand (pEdict, "sgren\n");
                        }
                        else if (iGrenadeType < 100)
                        {
                                if (g_bIsOldCS15)
                                        FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 3\n");
                                else
                                        FakeClientCommand (pEdict, "flash\n");
                        }

just after this:
Code:

                if (pBot->bot_money > 300)
                {

and change 300 with for instance, 600?

this way it should first buy a grenade and then (if we place a second money-checking part) a defusal kit.

Would this be the reason why they so seldom(or never) buy (therefore use) grenades?

Pierre-Marie Baty 26-05-2004 23:32

Re: doesn't this prevent em buying grenades?
 
Yes, you are right, however that's the way the code worked in the original POD-Bot. The bots wouldn't buy grenades if they had a defuse kit and vice versa.

I could have removed it... but at first I wanted to get the bot running exactly like in 2.5 ; it's come a long way since :)

bluebyte 27-05-2004 10:50

Re: doesn't this prevent em buying grenades?
 
1 Attachment(s)
I have modified the source as i said and now they buy and use grenades :D I didn't touch anything else in the source code. Also, i have optimized the dll with intel compiler for P2/P3 processors (this is why the .dll is a little big). I hope that I have not screwed some stuff :P C ya...

>BKA< T Wrecks 27-05-2004 11:05

Re: doesn't this prevent em buying grenades?
 
Hey, thanks bluebyte! Gonna try your dll as soon as I have time... looks like we got another coding nut to help sPlOrYgOn, huh? =)

bluebyte 27-05-2004 22:11

Re: doesn't this prevent em buying grenades?
 
maybe, i'd be glad to :)

sPlOrYgOn 28-05-2004 04:29

Re: doesn't this prevent em buying grenades?
 
Okay I have changed from:
Code:

  // Needs an Item ?
  else if (pBot->iBuyCount < 7)
  {
      // Care first about buying Armor
      if (pBot->iBuyCount == 4)
      {
        if ((pBot->pEdict->v.armorvalue == 0) && (pBot->bot_money > 650))
        {
            if (pBot->bot_money > 1000)
            {
              if (g_bIsOldCS15)
                  FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 2\n");
              else
                  FakeClientCommand (pEdict, "vesthelm\n");
            }
            else
            {
              if (g_bIsOldCS15)
                  FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 1\n");
              else
                  FakeClientCommand (pEdict, "vest\n");
            }
        }
      }

      // Buy Grenade or Defuse Kit
      else
      {
        if (pBot->bot_money > 300)
        {
            // If Defusion Map & Counter buy Defusion Kit
            if ((g_iMapType & MAP_DE) && (pBot->bot_team == TEAM_CS_COUNTER) && !pBot->b_has_defuse_kit)
            {
              if (g_bIsOldCS15)
                  FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 6\n");
              else
                  FakeClientCommand (pEdict, "defuser\n");
            }

            // Else buy Grenade
            else
            {
              int iGrenadeType = RANDOM_LONG (1, 100);

              // Focus on HE Grenades
              if (iGrenadeType < 70)
              {
                  if (g_bIsOldCS15)
                    FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 4\n");
                  else
                    FakeClientCommand (pEdict, "hegren\n");
              }
              else if (iGrenadeType < 90)
              {
                  if (g_bIsOldCS15)
                    FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 5\n");
                  else
                    FakeClientCommand (pEdict, "sgren\n");
              }
              else if (iGrenadeType < 100)
              {
                  if (g_bIsOldCS15)
                    FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 3\n");
                  else
                    FakeClientCommand (pEdict, "flash\n");
              }
            }
        }
      }

to
Code:

  // Needs an Item ?
  else if (pBot->iBuyCount < 7)
  {
      // Care first about buying Armor
      if (pBot->iBuyCount == 4)
      {
        if ((pBot->pEdict->v.armorvalue < 80) && (pBot->bot_money > 650))
        {
            if (pBot->bot_money > 1000)
            {
              if (g_bIsOldCS15)
                  FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 2\n");
              else
                  FakeClientCommand (pEdict, "vesthelm\n");
            }
            else
            {
              if (g_bIsOldCS15)
                  FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 1\n");
              else
                  FakeClientCommand (pEdict, "vest\n");
            }
        }
      }

      if (pBot->bot_money > 600)
      {
        int iGrenadeType = RANDOM_LONG (1, 100);

        // Focus on HE Grenades
        if (iGrenadeType < 70)
        {
            if (g_bIsOldCS15)
              FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 4\n");
            else
              FakeClientCommand (pEdict, "hegren\n");
        }
        else if (iGrenadeType < 90)
        {
            if (g_bIsOldCS15)
              FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 5\n");
            else
              FakeClientCommand (pEdict, "sgren\n");
        }
        else if (iGrenadeType < 100)
        {
            if (g_bIsOldCS15)
              FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 3\n");
            else
              FakeClientCommand (pEdict, "flash\n");
        }
      }

      if (pBot->bot_money > 300)
      {
        // If Defusion Map & Counter buy Defusion Kit
        if ((g_iMapType & MAP_DE) && (pBot->bot_team == TEAM_CS_COUNTER) && !pBot->b_has_defuse_kit)
        {
            if (g_bIsOldCS15)
              FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 6\n");
            else
              FakeClientCommand (pEdict, "defuser\n");
        }
      }

Is this what you wanted?

bluebyte 28-05-2004 11:15

Re: doesn't this prevent em buying grenades?
 
I made it like that:

Code:

        else if (pBot->iBuyCount < 7)
{
        // Care first about buying Armor
        if (pBot->iBuyCount == 4)
        {
                if ((pBot->pEdict->v.armorvalue == 0) && (pBot->bot_money > 650))
                {
                        if (pBot->bot_money >= 1000)
                        {
                        if (g_bIsOldCS15)
                                FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 2\n");
                        else
                                FakeClientCommand (pEdict, "vesthelm\n");
                        }
                        else if (pBot->bot_money >= 650)
                        {
                        if (g_bIsOldCS15)
                                FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 1\n");
                        else
                                FakeClientCommand (pEdict, "vest\n");
                        }
                }
        }
 
        // Buy Grenade or Defuse Kit
 
                if (pBot->bot_money >= 300)
                {
                        int iGrenadeType = RANDOM_LONG (1, 100);
 
                        // Focus on HE Grenades
                        if (iGrenadeType < 75)
                        {
                                if (g_bIsOldCS15)
                                        FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 4\n");
                                else
                                        FakeClientCommand (pEdict, "hegren\n");
                        }
                        else if (iGrenadeType < 82)
                        {
                                if (g_bIsOldCS15)
                                        FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 5\n");
                                else
                                        FakeClientCommand (pEdict, "sgren\n");
                        }
                        else
                        {
                                if (g_bIsOldCS15)
                                        FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 3\n");
                                else
                                        FakeClientCommand (pEdict, "flash\n");
                        }
          }
 
// If Defusion Map & Counter buy Defusion Kit
                if ((g_iMapType & MAP_DE) && (pBot->bot_team == TEAM_CS_COUNTER) && !pBot->b_has_defuse_kit && pBot->bot_money >= 200)
                {
                if (g_bIsOldCS15)
                FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 6\n");
                else
                FakeClientCommand (pEdict, "defuser\n");
                }
 
        pBot->iBuyCount = 0; // Finished Buying
        return;
}
 
pBot->iBuyCount = 0; // Finished Buying
 
return;
}

I think we'd better separate the money checking part for the grenades from the money checking part of defuse kit. I mean here:

Code:


        // Buy Grenade or Defuse Kit
 
                if (pBot->bot_money >= 300)

instead of 600. Also I had to remove one of the elses below(in // Finished Buying part). Finally i made them buy a lil bit more HE and a lil bit less SMOKE greandes. I recommend u to take my code instead, to save u some time. U can trust me i have tested this code :). So here is the whole stuff ready to copy-paste:

Code:

// Needs an Item ?
else if (pBot->iBuyCount < 7)
{
        // Care first about buying Armor
        if (pBot->iBuyCount == 4)
        {
                if ((pBot->pEdict->v.armorvalue == 0) && (pBot->bot_money > 650))
                {
                        if (pBot->bot_money >= 1000)
                        {
                        if (g_bIsOldCS15)
                                FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 2\n");
                        else
                                FakeClientCommand (pEdict, "vesthelm\n");
                        }
                        else if (pBot->bot_money >= 650)
                        {
                        if (g_bIsOldCS15)
                                FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 1\n");
                        else
                                FakeClientCommand (pEdict, "vest\n");
                        }
                }
        }
        // Buy Grenade or Defuse Kit
                if (pBot->bot_money >= 300)
                {
                        int iGrenadeType = RANDOM_LONG (1, 100);
                        // Focus on HE Grenades
                        if (iGrenadeType < 75)
                        {
                                if (g_bIsOldCS15)
                                        FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 4\n");
                                else
                                        FakeClientCommand (pEdict, "hegren\n");
                        }
                        else if (iGrenadeType < 82)
                        {
                                if (g_bIsOldCS15)
                                        FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 5\n");
                                else
                                        FakeClientCommand (pEdict, "sgren\n");
                        }
                        else
                        {
                                if (g_bIsOldCS15)
                                        FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 3\n");
                                else
                                        FakeClientCommand (pEdict, "flash\n");
                        }
          }
 
// If Defusion Map & Counter buy Defusion Kit
                if ((g_iMapType & MAP_DE) && (pBot->bot_team == TEAM_CS_COUNTER) && !pBot->b_has_defuse_kit && pBot->bot_money >= 200)
                {
                if (g_bIsOldCS15)
                FakeClientCommand (pEdict, "buy;menuselect 8;menuselect 6\n");
                else
                FakeClientCommand (pEdict, "defuser\n");
                }
        pBot->iBuyCount = 0; // Finished Buying
        return;
}
pBot->iBuyCount = 0; // Finished Buying
return;
}

Plz note that after these changes the defuse kit became kind of lower-priority, I mean it comes after the grenades. (also note that i added that money checking for the defuse kit to it's if header). I this is how it should be now; since IMHO many players first prefer first buying grenades.

sPlOrYgOn 29-05-2004 04:23

Re: doesn't this prevent em buying grenades?
 
k.
Your changes have been added.


All times are GMT +2. The time now is 11:30.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.