.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Need some help with pickup pistols (http://forums.bots-united.com/showthread.php?t=3016)

The Storm 21-11-2004 17:11

Need some help with pickup pistols
 
I try many thinks and I can't get the bots to pickup weapons correctly.
On my last test if there is a pistol on the ground and bot have primary weapon, he don't switch to pistol and drop his primary weapon and after that he drop the pistol and else.

So can I do the pickup funciton to be a other task like PICKUP_PISTOL and if this is possibly how can I do it.
Sorry for stuped question but you knows that I'm new C++ coder(I now learning C++) and I'm new bot coder.Many thinks!!!
But I realy wont to continue this bot and I hope that all guys in this forums who can help me will help me :)

But for now don't tell me all that I must do, tell me only some thinks becorse I wont to do it with my ideas.I just wont some help for start and I hope that I will do the other thinks alone.

@$3.1415rin 21-11-2004 17:22

Re: Need some help with pickup pistols
 
you have to switch to the secondary weapon already some time in advance, because switching weapons is done via messages, therefore it needs time, and the animations maybe, too.

The Storm 21-11-2004 17:47

Re: Need some help with pickup pistols
 
But yes I use SelectWeaponbyNumber(pBot, iWeaponNum); to switch to pistol but is not working.
I try only with pistol pickup code and the bots pickup pistols correctly and don't drop his primary weapon.
But when I use pistol pickup code and primary pickup code togeder is not working.
I don't know what is the reason.

Pierre-Marie Baty 21-11-2004 21:48

Re: Need some help with pickup pistols
 
What Aspirin meant is that there needs to be a delay (at least one frame time) between weapon switching and weapon dropping. If you make your bot issue the "drop" client command right after your SelectWeaponByNumber() function, the bot will not drop the right weapon. You must make your bot select the right weapon, WAIT a few frames, and only then drop it.

Some client commands are not processed by the engine right at the time you issue them, but are buffered so that they are processed at the end of the frame, or at the beginning of the next frame. I suspect that is what's happening with the weapon selection client command.

What you can do, is not allow the bot to send the "drop" client command unless you are CERTAIN that it's holding the right weapon in its hands (by continuously checking its current weapon, for example, or else by catching the weaponselect network message).

The Storm 22-11-2004 10:54

Re: Need some help with pickup pistols
 
OK I try with wait time but again is not working.
I think that the two codes for Secndary and Primari weapon pickup are meset up are togeder.
So I post the code here but I post it clean with no wait times becose maybe there is a mistake in the code.Wait time is not working.

Code:

                  // Near to Weapon ?
                        else if(f_item_distance<50)
                        {
                            // Secondary weapon.
                            int iWeaponNum = 0;
 
                            for (i = 0; i < 7; i++)
                            {
                                  if (pBot->pEdict->v.weapons & (1 << cs_weapon_select[i].iId))
                                          iWeaponNum = i;
                            }
 
                            if (iWeaponNum > 0)
                            {
                              if(pBot->current_weapon.iId != cs_weapon_select[iWeaponNum].iId)
                                  {
                              if(pBot->current_weapon.iId != CS_WEAPON_INSWITCH)
                                  SelectWeaponbyNumber(pBot, iWeaponNum);
                                  }
                                  else
                                  FakeClientCommand(pEdict, "drop","", NULL);
                                  if (BotHasShield (pBot)) // If we have the shield...
                                  FakeClientCommand(pEdict, "drop","", NULL); // discard both shield and pistol
                            }
                            else
                                    pBot->iNumWeaponPickups++;
                        }
                        else
                        {
                                // Primary weapon.
                                int iWeaponNum = HighestWeaponOfEdict(pEdict);
                            if (iWeaponNum > 6 || BotHasPrimaryWeapon(pBot) || BotHasShield (pBot))
                                {
                                    if(pBot->current_weapon.iId != cs_weapon_select[iWeaponNum].iId)
                                        {
                                        if(pBot->current_weapon.iId != CS_WEAPON_INSWITCH)
                                                SelectWeaponbyNumber(pBot,iWeaponNum);
                                        }
                                        else
                                        FakeClientCommand(pEdict, "drop","", NULL);
 
                                }
                                else
                                        pBot->iNumWeaponPickups++;
                        }
                        break;

Tell me where I mistake.

@$3.1415rin 22-11-2004 18:24

Re: Need some help with pickup pistols
 
is this really supposed to be this way :

PHP Code:

else if(f_item_distance<50)
             {
                
// Secondary weapon.
               
[....]
             }
             else
             {
                 
// Primary weapon.
              
[....]   
             }
             break; 

or was i counting a wrong number of { and } ?

The Storm 22-11-2004 18:57

Re: Need some help with pickup pistols
 
What do you mean ???:(

If I do it like this
PHP Code:

  else if(f_item_distance<50)
              {
                 
// Primary weapon.
                 
[....]
              }
              else
              {
                 
// Secondary weapon.
               
[....]   
              }
              break; 

This way is not working becose if I do that the bots don't pickup pistol never.I don't know what is the reason
</font></font>

Pierre-Marie Baty 22-11-2004 19:35

Re: Need some help with pickup pistols
 
aspirin is right, this code can't work :)

if you want to understand why, indent your code better and look at how the bot decides whether it's a primary or a secondary weapon...

The Storm 22-11-2004 19:51

Re: Need some help with pickup pistols
 
Hmm is there way to make the bots to pickup pistols with other task like PICKUP_PISTOL or something else.
And I can't understand where I wrong in the code.

@$3.1415rin 27-11-2004 13:46

Re: Need some help with pickup pistols
 
don't despair, some bugs take month to be found, if ever. and I guess noone can really help you here, just based on a few lines of code.

for my post above, what I meant : I meant that the decision if it's a secondary or primary weapon doesnt have anything to do with distance, therefore I asked if that was right


All times are GMT +2. The time now is 04:25.

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