Member
Status: Offline
Posts: 33
Join Date: Sep 2009
Location: Bulgaria
|
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 
|