.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   The RealBot 'Source' (http://forums.bots-united.com/forumdisplay.php?f=52)
-   -   reload bug (http://forums.bots-united.com/showthread.php?t=2072)

Josh_Borke 24-06-2004 17:34

reload bug
 
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.

Josh_Borke 25-06-2004 00:24

Re: reload bug
 
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];
 
          }
  }


stefanhendriks 25-06-2004 09:42

Re: reload bug
 
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.

Josh_Borke 25-06-2004 16:23

Re: reload bug
 
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 ???:(

Josh_Borke 26-06-2004 06:59

Re: reload bug
 
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.

Whistler 26-06-2004 10:56

Re: reload bug
 
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)
        {


Josh_Borke 26-06-2004 15:59

Re: reload bug
 
what file is that?

stefanhendriks 26-06-2004 16:53

Re: reload bug
 
@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 ;)

Josh_Borke 28-06-2004 03:04

Re: reload bug
 
doing that change fixed the reload bug for my server

Whistler 29-06-2004 03:48

Re: reload bug
 
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.


All times are GMT +2. The time now is 09:54.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.