I thought that bots were reloading way too infrequently. They sometimes engage the enemy with nearly-empty clips. So i decided to try to fix this. I wrote a method in bot.cpp. here:
Code:
void BotCheckReload(bot_t *pBot, edict_t *pEdict)//bluebyte
{
if (!(pBot->bIsReloading) && FNullEnt (pBot->pBotEnemy)
&& (pBot->current_weapon.iAmmo1 > 0) && !(pBot->iStates & STATE_HEARINGENEMY)
&& !(pBot->iStates & STATE_SEEINGENEMY) )
{
int maxClip;//bluebyte
switch (pBot->current_weapon.iId)//bluebyte
{
case CS_WEAPON_P228: maxClip = 13 ; break;
case CS_WEAPON_ELITE: maxClip = 30 ; break;
case CS_WEAPON_FIVESEVEN: maxClip = 20; break;
case CS_WEAPON_DEAGLE: maxClip = 7 ; break;
case CS_WEAPON_USP: maxClip = 12 ; break;
case CS_WEAPON_GLOCK18: maxClip = 20 ; break;
case CS_WEAPON_M3: maxClip = 8 ; break;
case CS_WEAPON_XM1014: maxClip = 7 ; break;
case CS_WEAPON_MP5NAVY: maxClip = 30 ; break;
case CS_WEAPON_MAC10: maxClip = 30 ; break;
case CS_WEAPON_P90: maxClip = 50 ; break;
case CS_WEAPON_UMP45: maxClip = 25 ; break;
case CS_WEAPON_TMP: maxClip = 30 ; break;
case CS_WEAPON_M4A1: maxClip = 30 ; break;
case CS_WEAPON_AK47: maxClip = 30 ; break;
case CS_WEAPON_SG552: maxClip = 30 ; break;
case CS_WEAPON_AUG: maxClip = 30 ; break;
case CS_WEAPON_G3SG1: maxClip = 20 ; break;
case CS_WEAPON_SG550: maxClip = 30 ; break;
case CS_WEAPON_SCOUT: maxClip = 10 ; break;
case CS_WEAPON_AWP: maxClip = 10 ; break;
case CS_WEAPON_M249: maxClip = 100 ; break;
case CS_WEAPON_SHIELDGUN: maxClip = 0 ; break;
case CS_WEAPON_GALIL: maxClip = 35 ; break;
case CS_WEAPON_FAMAS: maxClip = 25 ; break;
default: maxClip = 0;//for knives & grenades
}//end switch
//bluebyte: we should reload more frequently
if (pBot->current_weapon.iClip < (0.8*maxClip) )
{
pEdict->v.button |= IN_RELOAD;
pBot->bIsReloading = TRUE;
}
}//end if
}//end BotCheckReload
They reload if they don't have an enemy, if don't see an enemy, if don't hear an enemy, if aren't reloading already, and if they have enough ammo to reload ( > 0) .
If all these conditions are satisfied, i proceed and get the clip capacity of the current weapon that the bot is using. the switch-case block server this purpose. I do this because there is no variable in the code that keeps track of this already (or i missed it). After i got maxClip for current weapon, i check if current number of bullets in the clip is less than %80 of maxclip. (for instance, if the bot is using mp5navy and has 23 bullets, he reloads, but if it has, say, 24 bullets or more, it doesn't) If it is less, then the bot reloads. If not, they don't reload.
I call this method in bot think, at the beginning of these tasks: TASK_NORMAL, TASK_ENEMYHUNT, TASK_SEEKCOVER (but here not at the beginning of the task, but just after " // Enter look direction from previously calculated positions" code (after the else), TASK_PAUSE, TASK_CAMP, TASK_HIDE, TASK_MOVETOPOSITION and finally TASK_FOLLOWUSER.
I have tested my modifications for about 1 hour now, and it seems to work well. I already sent this code to SPlorYGon but i'm not sure if he will decide to include it or not, i just wrote this thread to get some feedback. If you guys request, i may prepare a binary for you. Also, it is likely that this will be my last coding about podbot, since i'll work on something else, anyway i always remain as a part of this "warm" community