.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Cyborg Factory > YaPB
YaPB Yet another POD-Bot flavor by Whistler and Jeefo Counter-Strike

Reply
 
Thread Tools
YaPB 1.0.0.0 modification problem
Old
  (#1)
Serious Sam
Member
 
Serious Sam's Avatar
 
Status: Offline
Posts: 33
Join Date: Sep 2009
Location: Bulgaria
Question YaPB 1.0.0.0 modification problem - 17-09-2009

I tried to change the weapon prefs configuration from the standart cfg file to a executable cvar, so that the bot could have different weapon prefs for each map, using the amx mod x feature to execute map specific cvars.

First, I deleted in the botweapons.cfg everything after "# Weapon Priorities for a Normal Standard Bot" and in server.cfg I added the following lines with default weapon prefs for maps that dont have any specific prefs set

Code:
yapb_norwepprefs "0,2,1,5,6,3,4,25,19,18,20,21,8,10,12,7,11,13,9,22,24,23,14,16,17,15"
yapb_agrwepprefs "0,1,2,4,5,6,3,18,19,25,20,21,17,15,14,16,23,24,22,7,8,10,12,9,13,11"
yapb_defwepprefs "0,2,1,4,3,5,6,8,7,12,10,11,9,13,22,24,23,16,14,25,15,17,18,21,20,19"
Then I made the following changes to dllapi.cpp :

after the
Code:
cvar_t g_cvarBotBuy = {"yapb_botbuy", "1"};
line I added these:
Code:
cvar_t g_cvarNWP = {"yapb_norwepprefs", "0,2,1,5,6,3,4,25,19,18,20,21,8,10,12,7,11,13,9,22,24,23,14,16,17,15"};
cvar_t g_cvarAWP = {"yapb_agrwepprefs", "0,1,2,4,5,6,3,18,19,25,20,21,17,15,14,16,23,24,22,7,8,10,12,9,13,11"};
cvar_t g_cvarDWP = {"yapb_defwepprefs", "0,2,1,4,3,5,6,8,7,12,10,11,9,13,22,24,23,16,14,25,15,17,18,21,20,19"};
after the
Code:
CVAR_REGISTER(&g_cvarBotBuy);
line I added these:
Code:
   CVAR_REGISTER(&g_cvarNWP);
   CVAR_REGISTER(&g_cvarAWP);
   CVAR_REGISTER(&g_cvarDWP);
I replaced this code:
Code:
         else
         {
            if (FStrEq(szBuffer, "[NORMAL]"))
               ptrWeaponPrefs = NormalWeaponPrefs;
            else if (FStrEq(szBuffer, "[AGRESSIVE]"))
               ptrWeaponPrefs = AgressiveWeaponPrefs;
            else if (FStrEq(szBuffer, "[DEFENSIVE]"))
               ptrWeaponPrefs = DefensiveWeaponPrefs;
            else
            {
               pszStart = szBuffer;
               for (i = 0; i < NUM_WEAPONS; i++)
               {
                  pszEnd = strchr(pszStart, ',');
                  *ptrWeaponPrefs++ = atoi(pszStart);
                  pszStart = pszEnd + 1;
               }
            }
         }
with this:
Code:
            pszStart = (char *)CVAR_GET_STRING(g_cvarNWP.name);
            ptrWeaponPrefs = NormalWeaponPrefs;
            for (i = 0; i < NUM_WEAPONS; i++)
            {
                 pszEnd = strchr(pszStart, ',');
                 *ptrWeaponPrefs++ = atoi(pszStart);
                 pszStart = pszEnd + 1;
            }

            pszStart = (char *)CVAR_GET_STRING(g_cvarAWP.name);
            ptrWeaponPrefs = AgressiveWeaponPrefs;
            for (i = 0; i < NUM_WEAPONS; i++)
            {
                 pszEnd = strchr(pszStart, ',');
                 *ptrWeaponPrefs++ = atoi(pszStart);
                 pszStart = pszEnd + 1;
            }

            pszStart = (char *)CVAR_GET_STRING(g_cvarDWP.name);
            ptrWeaponPrefs = DefensiveWeaponPrefs;
            for (i = 0; i < NUM_WEAPONS; i++)
            {
                 pszEnd = strchr(pszStart, ',');
                 *ptrWeaponPrefs++ = atoi(pszStart);
                 pszStart = pszEnd + 1;
            }
At this point I thought I was ready, the code compiled with no errors or warnings, the game started with no problems, I tested it out on cs_mansion, in the amx config file for cs_mansion I added the new cvars and gave the bots prefs so that all personalities should prefer ak-47 and m4a1, but when I tested it in game, they still were buying according to their default prefs. When I checked the new cvars in the console, they were set the way they should, which makes the problem somewhere in the code, which is not suprising knowing that I'm not good with programing.

So, if someone can help, please do
  
Reply With Quote
Re: YaPB 1.0.0.0 modification problem
Old
  (#2)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: YaPB 1.0.0.0 modification problem - 18-09-2009

looks like the cvar is set AFTER the prefs are read into the arrays.
a better way may be changing the buy code to use the cvars instead of the arrays.
  
Reply With Quote
Re: YaPB 1.0.0.0 modification problem
Old
  (#3)
Serious Sam
Member
 
Serious Sam's Avatar
 
Status: Offline
Posts: 33
Join Date: Sep 2009
Location: Bulgaria
Default Re: YaPB 1.0.0.0 modification problem - 18-09-2009

Ok, but, even if this is possible, I cant quite get it right.
In function "void CBaseBot::BuyStuff()" that is in bot_ai.cpp after the line
Code:
int* ptrWeaponTab = ptrWeaponPrefs[m_ucPersonality] + NUM_WEAPONS;
I added
Code:
int i;
   char *pszStart;
   char *pszEnd;
   switch (m_ucPersonality)
   {
        case PERSONALITY_NORMAL:
            pszStart = (char *)CVAR_GET_STRING("sb_norwepprefs");
            for (i = 0; i < NUM_WEAPONS; i++)
            {
                 pszEnd = strchr(pszStart, ',');
                 *ptrWeaponTab++ = atoi(pszStart);
                 pszStart = pszEnd + 1;
            }
            break;

        case PERSONALITY_AGRESSIVE:
            pszStart = (char *)CVAR_GET_STRING("sb_agrwepprefs");
            for (i = 0; i < NUM_WEAPONS; i++)
            {
                 pszEnd = strchr(pszStart, ',');
                 *ptrWeaponTab++ = atoi(pszStart);
                 pszStart = pszEnd + 1;
            }
            break;

        case PERSONALITY_DEFENSIVE:
            pszStart = (char *)CVAR_GET_STRING("sb_defwepprefs");
            for (i = 0; i < NUM_WEAPONS; i++)
            {
                 pszEnd = strchr(pszStart, ',');
                 *ptrWeaponTab++ = atoi(pszStart);
                 pszStart = pszEnd + 1;
            }
            break;

   }
and the result is that when a bot tries to buy a weapon the game crashes with runtime error
  
Reply With Quote
Re: YaPB 1.0.0.0 modification problem
Old
  (#4)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: YaPB 1.0.0.0 modification problem - 22-09-2009

try adding "ptrWeaponTab = ptrWeaponPrefs[m_ucPersonality] + NUM_WEAPONS;" after the stuff you added, as your code changed the ptrWeaponTab pointer which will be used later.
  
Reply With Quote
Re: YaPB 1.0.0.0 modification problem
Old
  (#5)
Serious Sam
Member
 
Serious Sam's Avatar
 
Status: Offline
Posts: 33
Join Date: Sep 2009
Location: Bulgaria
Default Re: YaPB 1.0.0.0 modification problem - 22-09-2009

It doesnt work, I still get the runtime error when bots try to buy. Looks like I might have to scrap this idea and try to make it read the weapon prefs for the different maps from the botweapons.cfg file, but for that Ill need to find a function in the hlsdk that returns the current map name, and it also won't be nicer than the cvar idea.
  
Reply With Quote
Reply

Tags
cvars, weapons, yapb


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com