.:: 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 > POD-Bot mm > Releases, Installers, Docs & Coding
Releases, Installers, Docs & Coding Where the official development happens

Reply
 
Thread Tools
my reload fix
Old
  (#1)
bluebyte
Guest
 
Status:
Posts: n/a
Default my reload fix - 03-06-2004

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

Last edited by bluebyte; 03-06-2004 at 23:25..
  
Reply With Quote
Re: my reload fix
Old
  (#2)
>BKA< T Wrecks
Moderator [PBmm/Waypointing]& PODBot mm waypointer
 
>BKA< T Wrecks's Avatar
 
Status: Offline
Posts: 1,492
Join Date: Feb 2004
Location: C.C.A.A., Germania
Default Re: my reload fix - 03-06-2004

Awwww, man! What a pity - you come, post 2-3 very useful things, and now you tell us this is probably the last thing you'll ever do with PODBot! :'(
Ok, in any case I think the stuff you coded here really makes sense; at least it's the way I'd prefer bots to behave. No reloading orgies whenever 1 or 2 bullets have been fired, yet no facing enemies with the final bullet left... thumbs up!
You only made some tiny mistakes concerning clip capacity:
M3 Shotgun is 8, not 7
XM1014 Auto-Shottie is 7, not 8
SG 550 is 30, not 20
...and why do your FAMAS and GALIL have 0? I can't check right now, cause my CS 1.6 is unavailable due to the last CS update... as usual... 9_9
Anyway, thanks for this contribution and good luck with whatever you're up to... :'( !!



Roses are #FF0000, violets are #0000FF // all my base, are belong to you.

  
Reply With Quote
Re: my reload fix
Old
  (#3)
bluebyte
Guest
 
Status:
Posts: n/a
Default Re: my reload fix - 03-06-2004

okay, thanks for your corrections Wrecks, I edited the code to reflect the right values now. Also, i forgot to mention, they are zero because i haven't played 1.6 therefore i don't know the values for galil and famas (have no clue about CS_WEAPON_SHIELDGUN also) . So if somebody can supply me with the correct maxclip values, i'll update them. C ya
  
Reply With Quote
Re: my reload fix
Old
  (#4)
Dark JP2
Guest
 
Status:
Posts: n/a
Default Re: my reload fix - 03-06-2004

galil: 35 shots/clip
famas: 25 shots/clip

to the shieldgun <- what does that thing mean?
  
Reply With Quote
Re: my reload fix
Old
  (#5)
sPlOrYgOn
<-- He did it.
 
sPlOrYgOn's Avatar
 
Status: Offline
Posts: 1,558
Join Date: Jan 2004
Location: Los Angeles, California, USA, North America, Earth, Solar System, Milky Way.
Default Re: my reload fix - 04-06-2004

yea you already gave this to me..
and i cleaned it up and made it easier to read..
Code:
void BotCheckReload (bot_t *pBot)  // bluebyte
{
   if (!pBot->bIsReloading && FNullEnt (pBot->pBotEnemy) && (pBot->current_weapon.iAmmo1 > 0)
      && !(pBot->iStates & STATE_SEEINGENEMY) && !(pBot->iStates & STATE_SUSPECTENEMY)
      && !(pBot->iStates & STATE_HEARINGENEMY))
   {
      int iMaxClip;  // bluebyte

      switch (pBot->current_weapon.iId)  // bluebyte
      {
      case CS_WEAPON_M249:
         iMaxClip = 100;
         break;

      case CS_WEAPON_P90:
         iMaxClip = 50;
         break;

      case CS_WEAPON_GALIL:
         iMaxClip = 35;
         break;

      case CS_WEAPON_ELITE:
      case CS_WEAPON_MP5NAVY:
      case CS_WEAPON_TMP:
      case CS_WEAPON_MAC10:
      case CS_WEAPON_M4A1:
      case CS_WEAPON_AK47:
      case CS_WEAPON_SG552:
      case CS_WEAPON_AUG:
      case CS_WEAPON_SG550:
         iMaxClip = 30;
         break;

      case CS_WEAPON_UMP45:
      case CS_WEAPON_FAMAS:
         iMaxClip = 25;
         break;

      case CS_WEAPON_GLOCK18:
      case CS_WEAPON_FIVESEVEN:
      case CS_WEAPON_G3SG1:
         iMaxClip = 20;
         break;

      case CS_WEAPON_P228:
         iMaxClip = 13;
         break;

      case CS_WEAPON_USP:
         iMaxClip = 12;
         break;

      case CS_WEAPON_AWP:
      case CS_WEAPON_SCOUT:
         iMaxClip = 10;
         break;

      case CS_WEAPON_M3:
         iMaxClip = 8;
         break;

      case CS_WEAPON_DEAGLE:
      case CS_WEAPON_XM1014:
         iMaxClip = 7;
         break;

      default:  // for knives & grenades
         iMaxClip = 0;
      }

      // bluebyte: we should reload more frequently
      if (pBot->current_weapon.iClip < (0.8 * iMaxClip))
      {	
         pBot->pEdict->v.button |= IN_RELOAD;
         pBot->bIsReloading = TRUE;
      }
   }
}
  
Reply With Quote
Re: my reload fix
Old
  (#6)
>BKA< T Wrecks
Moderator [PBmm/Waypointing]& PODBot mm waypointer
 
>BKA< T Wrecks's Avatar
 
Status: Offline
Posts: 1,492
Join Date: Feb 2004
Location: C.C.A.A., Germania
Default Re: my reload fix - 04-06-2004

Hmmm... smart guy! You're right... this IS less complicated.



Roses are #FF0000, violets are #0000FF // all my base, are belong to you.

  
Reply With Quote
Reply


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

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