.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   f_move_speed = 0.0; and IN_ATTACK Problem (http://forums.bots-united.com/showthread.php?t=1683)

Tea 16-05-2004 17:55

f_move_speed = 0.0; and IN_ATTACK Problem
 
Code:


        if (pBot->f_duck_time > gpGlobals->time)
        pBot->f_move_speed = 0.0;
        {       
          pBot->f_duck_time = gpGlobals->time + 1.5;
          FakeClientCommand(pEdict, "say", "DUCKING", NULL);
          pEdict->v.button |= IN_ATTACK;  // fire the weapon
          return TRUE;
        }

Hi is me again, this is part of my shootnow(), If I remove the pBot->f_move_speed = 0.0; everything work fine, but if the pBot->f_move_speed = 0.0; active, the bots only call IN_ATTACK one time, if their enemy won't die in the first shot, than two bot will only facing each other and do nothing, I am sure the shootnow() keep calling in every frame since two bots keep saying DUCKING.

But if the bot can move forward only one little step, they can fire another shot. This also happen to breakable object, if the bot shoot at the window and if he can't break it in the first shoot, he just stand still before the window and do nothing, but if the bot can move forward a little step, then he can fire another shoot, please help.

sPlOrYgOn 16-05-2004 18:02

Re: f_move_speed = 0.0; and IN_ATTACK Problem
 
thats because the if statement is only for
pBot->f_move_speed = 0.0;
the other stuff will always run.
instead have it
Code:

  if (pBot->f_duck_time > gpGlobals->time)
    {
      pBot->f_move_speed = 0.0;
      pBot->f_duck_time = gpGlobals->time + 1.5;
      FakeClientCommand(pEdict, "say", "DUCKING", NULL);
      pEdict->v.button |= IN_ATTACK;  // fire the weapon
      return TRUE;
    }


Pierre-Marie Baty 16-05-2004 23:30

Re: f_move_speed = 0.0; and IN_ATTACK Problem
 
is it normal that with such a code the bot will keep ducking and firing forever ?

stefanhendriks 17-05-2004 08:39

Re: f_move_speed = 0.0; and IN_ATTACK Problem
 
hehe yes, i see it too now. The code should not say:

pBot->f_duck_time = gpGlobals->time + 1.5;

within the scope, it should just say:

pBot->pEdict->v.button |= IN_DUCK;

:D

Tea 17-05-2004 12:39

Re: f_move_speed = 0.0; and IN_ATTACK Problem
 
Actually my code is like this:

Code:


        if (pBot->f_duck_time > gpGlobals->time)
        pBot->f_move_speed = 0.0;
 
        if (RANDOM_LONG(1, 100) <= 100) //now 100% because I want to test it
        {       
        pBot->f_duck_time = gpGlobals->time + 1.5;
        FakeClientCommand(pEdict, "say", "DUCKING", NULL);
        pEdict->v.button |= IN_ATTACK; // fire the weapon
        return TRUE;
        }

Yes, I do want the bot duck for 1.5 sec and keep firing until the enemy die, the problem is the bot only fire one shoot(only call IN_ATTACK one time), but I am sure this code have called every frame since although the bot only fire one time, but they are keep saying DUCKING DUCKING DUCKING.......

If I remove the pBot->f_move_speed = 0.0; function and now the bot will duck but not duck and don't move, they will duck and move forward at the same time, but now they can keep shooting without problem until the enemy die.

Or am I mis-understand how pBot->f_move_speed = 0.0; work? I think it only make the bot don't move but do you mean it will make the bot totally pause ? If yes which command can make the bot only stop move but not pause ?

Tea 20-05-2004 12:14

Re: f_move_speed = 0.0; and IN_ATTACK Problem
 
Hmm no one know ? Or botman can you help please ?

sPlOrYgOn 20-05-2004 12:37

Re: f_move_speed = 0.0; and IN_ATTACK Problem
 
Code:

        if (pBot->f_duck_time < gpGlobals->time)
        {
                if (RANDOM_LONG(1, 100) <= 10)
                {
                        pBot->f_move_speed = 0.0;
                        pBot->f_duck_time = gpGlobals->time + 1.5;
                        FakeClientCommand(pEdict, "say", "DUCKING", NULL);
                        pEdict->v.button |= IN_ATTACK; // fire the weapon
                        return TRUE;
                }
        }

perhaps you wanted this?

they kept saying DUCKING because you made them say ducking 100% of the time..

botman 20-05-2004 15:18

Re: f_move_speed = 0.0; and IN_ATTACK Problem
 
You need to toggle the IN_ATTACK button on and off. If you keep setting it to IN_ATTACK during EVERY frame, it's the same thing as holding the trigger down (which will only fire ONE shot unless you are firing an automatic weapon).

Try something like this...
Code:

if (RANDOM_LONG(1, 100) <= 100) //now 100% because I want to test it
{
        pBot->f_duck_time = gpGlobals->time + 1.5;
        FakeClientCommand(pEdict, "say", "DUCKING", NULL);
        if (RANDOM_LONG(1, 2) == 1)
                pEdict->v.button |= IN_ATTACK; // fire the weapon
        else
                pEdict->v.button = 0;  // stop pressing the button
        return TRUE;
}

This will cause the IN_ATTACK button to rapidly toggle (randomly) on and off. It's the same sort of thing used in the code that respawns an HPB bot when playing deathmatch.

botman

Tea 22-05-2004 08:32

Re: f_move_speed = 0.0; and IN_ATTACK Problem
 
OMG it work now ! Botman THANK YOU VERY MUCH ! :D


All times are GMT +2. The time now is 15:50.

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