.:: 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 > RealBot > The RealBot 'Source'
The RealBot 'Source' Discuss things about the source code. You can here point out bugs, share ideas and code. Assign to become an 'official team member' and so on!

Reply
 
Thread Tools
reload bug
Old
  (#1)
Josh_Borke
Member
 
Status: Offline
Posts: 152
Join Date: Jun 2004
Default reload bug - 24-06-2004

Steps to reproduce bug:
Using the current WIP, if you load de_dust2 with approx 6 bots, on the first round they usually all run to the middle hill and start battling it out. Inevitably some/all of the bots will run out of ammo and then proceed to look at each other trying to figure out what to do. Pretty funny if you let them knife once they get close enough

Extra info:
I've been trying to see if I could fix this by putting in a check of how much ammo they have in cbot::FireWeapon() around line 963.
It successfully see that its clip is empty, but a check of it's remaining ammo returns 0.

Code:
   		int iTotalAmmo = current_weapon.iAmmo1;
   		int iCurrentAmmo = current_weapon.iClip;
   
   		if (iCurrentAmmo < 1 && (CarryWeaponType() == SECONDARY 
  			  || CarryWeaponType() == PRIMARY))
   		{
   				char msg[80];
   			    sprintf(msg,"I have %d ammo.",iTotalAmmo);
 				REALBOT_PRINT(NULL,"Reload",msg);
   				if (iTotalAmmo > 0) {
 					 REALBOT_PRINT(NULL,"Reload","I went to reload.");
 					 UTIL_BotPressKey (this, IN_RELOAD);
   				}
   				else {
 					 PickBestWeapon();
   				}
   		}
The reallog.txt returns
Code:
   RBPRINT->[FUNCTION 'Reload']-[Team NONE] : I have 0 ammo.
HTH

PS: I am running a dedicated linux server.

Last edited by Josh_Borke; 24-06-2004 at 17:38..
  
Reply With Quote
Re: reload bug
Old
  (#2)
Josh_Borke
Member
 
Status: Offline
Posts: 152
Join Date: Jun 2004
Default Re: reload bug - 25-06-2004

ok, not to be bothersome, but i'd like to see if i can help squash this bug, as such i've been trying to get my head around the code and do some further debugging.

Further debugging has shown that

bot_client.cpp ~ line 300 - BotClient_Valve_AmmoX function

it seems to be broken

index != (weapon_defs[ammo_index].iAmmo1 || weapon_defs[ammo_index].iId)

i see function pointers and my brain stops processing so I don't know where to go from here. I can see where it is called in engine.cpp. It looks like it hooks into meta above this so I am lost, HTH

PS. Here is the code for easy reference.

Code:
  // This message is sent whenever ammo ammounts are adjusted (up or down).
  void
  BotClient_Valve_AmmoX (void *p, int bot_index)
  {
    //DebugOut("bot_client: BotClient_Valve_AmmoX()\n");
    static int state = 0;		// current state machine state
    static int index;
    static int ammount;
    int ammo_index;
  
    if (state == 0)
  	{
  	  state++;
  	  index = *(int *) p;	// ammo index (for type of ammo)
  	}
    else if (state == 1)
  	{
  	  state = 0;
  
  	  ammount = *(int *) p;	// the ammount of ammo currently available
  
  	  bots[bot_index].m_rgAmmo[index] = ammount;	// store it away
  
  	  ammo_index = bots[bot_index].current_weapon.iId;
  
  	  // update the ammo counts for this weapon...
  	  bots[bot_index].current_weapon.iAmmo1 =
  	bots[bot_index].m_rgAmmo[weapon_defs[ammo_index].iAmmo1];
  
  	  bots[bot_index].current_weapon.iAmmo2 =
  	bots[bot_index].m_rgAmmo[weapon_defs[ammo_index].iAmmo2];
  
  	}
  }

Last edited by Josh_Borke; 25-06-2004 at 05:17..
  
Reply With Quote
Re: reload bug
Old
  (#3)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: reload bug - 25-06-2004

its good that you pointed this out, we should investigate this further. Either the message changed; the interception of my bot does not function, or... it never worked at all Lets figure it out.


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: reload bug
Old
  (#4)
Josh_Borke
Member
 
Status: Offline
Posts: 152
Join Date: Jun 2004
Default Re: reload bug - 25-06-2004

more info...
i've been trying to find a corresponding value for the 'index' value but haven't been able to.
it doesn't correspond to
Code:
current_weapon.iId
 weapon_defs[ammo_index].iPosition
 weapon_defs[ammo_index].iSlot
 weapon_defs[ammo_index].iFlags
 weapon_defs[ammo_index].iAmmo1
in fact, all of those come back as 0 except for iId ???
  
Reply With Quote
Re: reload bug
Old
  (#5)
Josh_Borke
Member
 
Status: Offline
Posts: 152
Join Date: Jun 2004
Default Re: reload bug - 26-06-2004

so, I collected some debug info but I was dumb and wasn't thinking exactly the best way to go about it so I just saved data each time the function was called.
the 2 'objects' i evaluated were weapon_defs[ammo_index] and bots[bot_index].current_weapon

unfortunately, they are not concretely connected ???
because ammo_index does not directly correspond to bots[bot_index].current_weapon except as bots[bot_index].current_weapon.iId

i'm going off of the assumption that index is connected in some way to bots[bot_index].current_weapon and I'm just trying to find the connection.
  
Reply With Quote
Re: reload bug
Old
  (#6)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: reload bug - 26-06-2004

I have also found this is still in the source code:
Code:
      if (ed)
	  {
		  index = UTIL_GetBotIndex (ed);
		  // is this message for a bot?
		  if (index != -1)
		  {
			  botMsgFunction = NULL;	// no msg function until known otherwise
			  botMsgEndFunction = NULL;	// no msg end function until known otherwise
			  botMsgIndex = index;	// index of bot receiving message
.......
				  else if (msg_type ==
					  GET_USER_MSG_ID (PLID, "WeaponList", NULL))
				  {
					  botMsgFunction = BotClient_CS_WeaponList;
but in CS 1.6 since the different way to send the WeaponList message this will just never get called. this may solve the problem:

Code:
   if (gpGlobals->deathmatch)
   {
      int index;

      if (msg_type == message_WeaponList)
         botMsgFunction = BotClient_CS_WeaponList;

      if (ed)
      {
         index = UTIL_GetBotIndex(ed);
         // is this message for a bot?
         if (index != -1)
         {

Last edited by Whistler; 26-06-2004 at 10:58..
  
Reply With Quote
Re: reload bug
Old
  (#7)
Josh_Borke
Member
 
Status: Offline
Posts: 152
Join Date: Jun 2004
Default Re: reload bug - 26-06-2004

what file is that?
  
Reply With Quote
Re: reload bug
Old
  (#8)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: reload bug - 26-06-2004

@Whistler, i did not know it was sent 'differently'. I thought it was never sent at all!

(hence, thats why i have all those properties in the buy_table.ini)...

thx , i'll try to get this workin


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: reload bug
Old
  (#9)
Josh_Borke
Member
 
Status: Offline
Posts: 152
Join Date: Jun 2004
Default Re: reload bug - 28-06-2004

doing that change fixed the reload bug for my server
  
Reply With Quote
Re: reload bug
Old
  (#10)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: reload bug - 29-06-2004

that message is just sent with a NULL entity so it won't get called into the "if (ed)"...
move it outside the "if(ed)" will be okay.
  
Reply With Quote
Reply


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 - 2025, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com