.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Something about msecval (http://forums.bots-united.com/showthread.php?t=344)

strelok 13-01-2004 07:02

Something about msecval
 
Why, when I use this code (by Count Floyd):

if (pBot->msecdel <= gpGlobals->time)
{
pBot->msecdel = gpGlobals->time + 0.5;
if (pBot->msecnum > 0)
pBot->msecval = 450.0/pBot->msecnum;
pBot->msecnum = 0;
}
else
pBot->msecnum++;
if (pBot->msecval < 1) // don't allow msec to be less than 1...
pBot->msecval = 1;

if (pBot->msecval > 100) // ...or greater than 100
pBot->msecval = 100;

my bots freeze (in the beginning of a round) for some seconds?

Pierre-Marie Baty 13-01-2004 07:40

Re: Something about msecval
 
This code is Rich "TheFatal" Whitehouse's method to estimate the duration of the next frame, in order to predict how long the pfnRunPlayerMove call for the movement of the bots should last. It looks correct, I find it strange that it could cause you trouble. Are you sure your problem comes from here ?

Anyway, there are several other methods to estimate the frame duration. The simplest one is to use the time difference between previous_time and gpGlobals->time in StartFrame(). But it is best to filter this value with time, and that's the purpose of msecnum and msecdel.

koraX 13-01-2004 08:16

Re: Something about msecval
 
PMB is right, This piece of code should not cause errors. I'm using it too.

botmeister 13-01-2004 09:09

Re: Something about msecval
 
Well, I've had poor results with this code, but I don't think it is the code that's the problem.

For example, I have two dedicated servers, both ar erunning realbot WIP#6 (and previously RB:AI ver 1.0). One server has the bots running around just slightly faster than they should, the other server has the bots running WAY faster than they should (2 or 3 x faster).

When I tried adding my own prototype bot into a game, I got the same problem - a bot that moved around way too fast depending on the server.

What i ended up doing, is setting the max speed of the bot entity to sv_maxspeed and that fixed the problem. I've added this "fix" to my bot manager (to be released soon), but a real solution to the problem should be found.

I posted this problem in botmans forum but no one had anything to offer at the time.

Pierre-Marie Baty 13-01-2004 16:36

Re: Something about msecval
 
botmeister, your method will force the bots to move as fast as can be, whether they carry heavy weapons or not. Have you tried hooking pfnSetClientMaxSpeed() and set each bot's max speed to this value ?

Bert 13-01-2004 17:19

Re: Something about msecval
 
I hook pfnSetClientMaxSpeed() and my bots move at the correct speed. I also use The Fatal's msec code, and I haven't noticed any problems with it.

Cheeseh 13-01-2004 17:54

Re: Something about msecval
 
Isn't this not the problem in CS where the bots angles overflow when they spawn? You should know all about that PM :D

edit: may aswell explain some:

If you are using botmans template, if the bots try to move more than 10 degrees (I think, maybe its 20) they stop and try to turn. If they're angles have overflown this might jumble up the bots interpretation and are not turning properly, meaning they will never turn the 10 degrees (or whatever) and will not move.

Use BotFixIdealAngles() function when a bot spawns.

.. or is It IdealYaw()...

Something like that... I don't use those functions anymore :D

Pierre-Marie Baty 13-01-2004 18:05

Re: Something about msecval
 
<offtopic>
how come there are a lot of bot developers in here and we never heard of their bots ? o_O
@Bert: You have an URL for your bot ? :)
</offtopic>

Pierre-Marie Baty 13-01-2004 18:08

Re: Something about msecval
 
@Cheeseh: Strelok is using Count Floyd's code, and CF obviously fixed this angle problems for quite a time already :)

Cheeseh 13-01-2004 18:12

Re: Something about msecval
 
Alright, well maybe they are just stopping to buy stuff eh? :p I haven't looked at CF's code, if you can debug, break when their move speed is 0 and see whats making it 0.

Bert 13-01-2004 20:47

Re: Something about msecval
 
[Off-topic]
I think there are alot of tiny bots out there on the net, afterall with Botman's template code and readme, it's amazingly easy to get a basic bot in a mod.
As for my bot, I released the first version a month ago or so, but it's nothing more than a modified HPBbot. It's for the mod Science and Industry (www.planethalflife.com/si) and it's more like a "Can I pull it off" release. There's some errors in the logic (Bots really like to kill scis) and it only comes with waypoints for 1 map. And it's not fully compatible with the latest version (97b). Try it if you like, but don't expect too much http://users.pandora.be/piele/MBFbot.zip . These days I seem to be stuck in an endless redesign cycle, I simply can not decide on what's the best way to handle things, so I keep changing stuff around :/
[/Offtopic]

botmeister 13-01-2004 21:19

Re: Something about msecval
 
Quote:

Originally Posted by Pierre-Marie Baty
botmeister, your method will force the bots to move as fast as can be, whether they carry heavy weapons or not. Have you tried hooking pfnSetClientMaxSpeed() and set each bot's max speed to this value ?

Thanks again, I'll give this one a try.

Pierre-Marie Baty 13-01-2004 23:42

Re: Something about msecval
 
@Bert: Okay, well, good luck, and btw when you come up with a "production release" of your bot we can make you part of Bots United perhaps (website, forum, etc.) :)

@botmeister: I find it curious that you never did. It's the way to do things, all CS bots hook pfnSetClientMaxSpeed() actually ! How come you never tried that ?

botmeister 14-01-2004 05:15

Re: Something about msecval
 
Quote:

I find it curious that you never did. It's the way to do things, all CS bots hook pfnSetClientMaxSpeed() actually ! How come you never tried that ?
I never did because I have not built much of a bot. Aside from the server management stuff, what I've done is enhanced existing bots which only goes so far.

I'm not sure how you would use the function just yet
void (*pfnSetClientMaxspeed) (const edict_t *pEdict, float fNewMaxspeed);

Can you give me a hint or two to move things along?

Pierre-Marie Baty 14-01-2004 05:48

Re: Something about msecval
 
in your array of bots, have a variable for each bot to store its current max speed. When pfnSetClientMaxspeed() is called upon a bot entity, send fNewMaxspeed to this variable. And when pfnRunPlayerMove() happens for the same bot, use this variable as the move_speed and strafe_speed parameter (if you want to make the bot run or strafe full speed, else divide it by two.)

botmeister 15-01-2004 06:20

Re: Something about msecval
 
Quote:

Originally Posted by Pierre-Marie Baty
in your array of bots, have a variable for each bot to store its current max speed. When pfnSetClientMaxspeed() is called upon a bot entity, send fNewMaxspeed to this variable. And when pfnRunPlayerMove() happens for the same bot, use this variable as the move_speed and strafe_speed parameter (if you want to make the bot run or strafe full speed, else divide it by two.)

Ok, from what I understand, pfnSetClientMaxspeed() is used to set the speed of a bot. What I'd need it for is to get the speed of a bot, since I do not know what the bots speed should be. So, are you saying that I hook onto the function, and whenever it gets called I grab whatever was passed to the function as the bots new speed?

Anyhow, what I'm doing is simply passing on everything I get from the pfnRunPlayerMove() hook which was called by the actual bot mod, so I don't understand why on some servers the bots run around real fast. I'll have another look at my code, perhaps there's a problem with passing on the same speeds all the time.

strelok 15-01-2004 06:56

Re: Something about msecval
 
[QUOTE=Are you sure your problem comes from here ?[/QUOTE]
And if I use this code:

if (pBot->msecdel <= gpGlobals->time) {
pBot->msecdel = gpGlobals->time + 1.0;
if (pBot->msecnum > 0)
pBot->msecval = 800/pBot->msecnum;
pBot->msecnum = 0;
}
else
pBot->msecnum++;
if (pBot->msecval < 1)
pBot->msecval = 1;
if (pBot->msecval > 100)
pBot->msecval = 100;

bots move slowly (I with primary weapon run faster, than they with a knife). Also do not freeze.

Pierre-Marie Baty 15-01-2004 11:38

Re: Something about msecval
 
@ botmeister: each time a player switches to a new weapon, his run speed changes. The function that the MOD code calls in the engine to change the client's max speed is SetClientMaxSpeed(). So yes, grab the value that is passed, and use it for your bots ; i.e. do this:
Code:

void pfnSetClientMaxspeed (const edict_t *pEdict, float fNewMaxspeed)
{
  int client_index = ENTINDEX ((edict_t *) pEdict) - 1; // get client index
 
  // is this message for a bot ? if so, remember its max speed
  if (players[client_index].is_racc_bot)
          players[client_index].Bot.BotMove.f_max_speed = fNewMaxspeed;
 
  (*g_engfuncs.pfnSetClientMaxspeed) (pEdict, fNewMaxspeed);
}

@ Strelok: it is *normal* that the msec code has some influence on the bot's speed, but your problem doesn't come from here, because the msec code is *correct*. You should not change it. Instead, check for the bot's max speed. There is a problem in CS 1.6 where the player's max speed isn't set at round start (max_speed is initially 0 because pfnSetClientMaxSpeed() isn't called at round start like in 1.5) but it becomes set only when players switch to a new weapon. It may explain why your bots don't move as long as they don't change weapons.

strelok 23-01-2004 06:39

Re: Something about msecval
 
2 Pierre-Marie Baty: It not a problem cs1.6. In cs1.5 all too most, but time of freezing is longer.

Pierre-Marie Baty 23-01-2004 07:41

Re: Something about msecval
 
curious...
does it occur also if you set the mp_freezetime CVAR to 0 ?

strelok 26-01-2004 14:24

Re: Something about msecval
 
NO:) If mp_freezetime = 0.0 all is normal.

Pierre-Marie Baty 26-01-2004 16:12

Re: Something about msecval
 
Check what is the bot's max speed DURING the freeze time and AFTER it... that might be the problem, somehow.

strelok 29-01-2004 10:20

Re: Something about msecval
 
max speed DURING the freeze time: cs1.5 = 1, cs1.6 = 320, AFTER it: cs1.5 = 250, cs1.6 = 320

Pierre-Marie Baty 29-01-2004 15:01

Re: Something about msecval
 
Okay guys, we have an issue here. 320 is NOT a valid client speed in Counter-Strike. In Half-Life, it is.

Counter-Strike 1.6 does NOT send their max speeds to clients anymore. It's useless for us to hook pfnSetClientMaxSpeed() anymore. We have to fix the bot's max speed OURSELVES.

I suggest having a look in eLiTe's TeamBot code. It's REALLY old stuff, but there is interesting stuff. Because that's how the early bots were setting their max speeds before the pfnSetClientMaxSpeed() was discovered.
Code:

// This function is redundant, but the switch statement could be useful in future...
void SetSpeed (bot_t *pBot)
{
  // This changes the bot's maximum speed depending on the weapon it is
  // currently using
 
  switch (pBot->current_weapon.iId)
  {
          case CS_WEAPON_P228:
                pBot->f_max_speed = 250;
                break;
          case CS_WEAPON_SCOUT:
                pBot->f_max_speed = 260;
                break;
          case CS_WEAPON_HEGRENADE:
                pBot->f_max_speed = 260;
                break;
          case CS_WEAPON_XM1014:
                pBot->f_max_speed = 240;
                break;
          case CS_WEAPON_C4:
                pBot->f_max_speed = 250;
                break;
          case CS_WEAPON_MAC10:
                pBot->f_max_speed = 250;
                break;
          case CS_WEAPON_AUG:
                pBot->f_max_speed = 240;
                break;
          case CS_WEAPON_SMOKEGRENADE:
                pBot->f_max_speed = 260;
                break;
          case CS_WEAPON_ELITE:
                pBot->f_max_speed = 250;
                break;
          case CS_WEAPON_USP:
                pBot->f_max_speed = 250;
                break;
          case CS_WEAPON_GLOCK18:
                pBot->f_max_speed = 250;
                break;
          case CS_WEAPON_AWP:
                pBot->f_max_speed = 210;
                break;
          case CS_WEAPON_MP5NAVY:
                pBot->f_max_speed = 250;
                break;
          case CS_WEAPON_M249:
                pBot->f_max_speed = 220;
                break;
          case CS_WEAPON_M3:
                pBot->f_max_speed = 230;
                break;
          case CS_WEAPON_M4A1:
                pBot->f_max_speed = 230;
                break;
          case CS_WEAPON_TMP:
                pBot->f_max_speed = 250;
                break;
          case CS_WEAPON_G3SG1:
                pBot->f_max_speed = 200;
                break;
          case CS_WEAPON_FLASHBANG:
                pBot->f_max_speed = 260;
                break;
          case CS_WEAPON_DEAGLE:
                pBot->f_max_speed = 250;
                break;
          case CS_WEAPON_SG552:
                pBot->f_max_speed = 235;
                break;
          case CS_WEAPON_AK47:
                pBot->f_max_speed = 221;
                break;
          case CS_WEAPON_KNIFE:
                pBot->f_max_speed = 260;
                break;
          case CS_WEAPON_P90:
                pBot->f_max_speed = 250;
                break;
          case CS_WEAPON_UMP45:
                pBot->f_max_speed = 250;
                break;
          case CS_WEAPON_FIVESEVEN:
                pBot->f_max_speed = 250;
                break;
          case CS_WEAPON_SG550:
                pBot->f_max_speed = 210;
                break;
  }
}

We have to apply this each time a bot changes weapons. Eventually it would be good to check if these old values are still correct after 2 or 3 Counter-Strike updates. It's now the only way to fix the bot's "speed hack" bugs.

botmeister 31-01-2004 07:26

Re: Something about msecval
 
Quote:

Originally Posted by Pierre-Marie Baty
We have to apply this each time a bot changes weapons. Eventually it would be good to check if these old values are still correct after 2 or 3 Counter-Strike updates. It's now the only way to fix the bot's "speed hack" bugs.

I knew something was going wrong. I had problems with the msec system, and the hook onto pfnSetClientMaxSpeed() seemed to correct the speed hack problem but I've noticed that the bots were still running around too fast. Also, I tried using sv_maxspeed but the cvar is not always initialized correctly. There's lots of bugs in CS 1.6 surrounding the speeds and my bet is that they broke the thing trying to hammer in the shield.

KaCaT 31-01-2004 17:48

Re: Something about msecval
 
I use pfnSetClientMaxSpeed() for my bot in CS 1.5 and pev->maxspeed in CS 1.6. They are working well for me :)

stefanhendriks 31-01-2004 23:06

Re: Something about msecval
 
I just get freaking nuts of CS 1.6 guys! Or should i say, get sick of this STEAM? Argh.

Pierre-Marie Baty 02-02-2004 19:28

Re: Something about msecval
 
Quote:

Originally Posted by KaCaT
I use pfnSetClientMaxSpeed() for my bot in CS 1.5 and pev->maxspeed in CS 1.6. They are working well for me :)

pEdict->v.maxspeed ? Hey, great ! How come we didn't think of it earlier ? wow, gotta credit KaCaT in my code now :D

Quote:

Originally Posted by botmeister
I knew something was going wrong. [...] There's lots of bugs in CS 1.6 surrounding the speeds and my bet is that they broke the thing trying to hammer in the shield.

No, actually I believe they did it on purpose to lower the network traffic. If you think about it it's completely stupid to send their max speeds to the clients over the network since the clients already know it (they're running the same game DLL, don't they ?) And since some players have the bad habit to switch weapons like crazy, I think it's wise they did so.
There are still a lot of things that could be removed from the network code. The CS netcode isn't one of the most clever ones around. Maybe TurtleRocker could tell us more about it.

botmeister 02-02-2004 20:06

Re: Something about msecval
 
OK, I agree PMB, it is good idea to optimize the netcode and they probably did remove it on purpose. However I still don't understand why sv_maxspeed was being initialized incorrectly.

stefanhendriks 02-02-2004 20:25

Re: Something about msecval
 
i don't get it either, but if pEdict->v.maxspeed works i have said nothing ;)

Pierre-Marie Baty 03-02-2004 00:05

Re: Something about msecval
 
"sv_maxspeed was not initialized correctly" because sv_maxspeed is a server CVAR, not a client one, which means that if the game DLL chooses to rely on this value for the players' movements, ALL the players will run at the same speed all the time. This can't be, because CS lets players have different run speeds given the weapon they are carrying. That's why the game DLL of Counter-Strike does NOT rely on sv_maxspeed, but let the clients adapt their max speeds individually, unlike other MODs which don't feature different player run speeds.

strelok 03-02-2004 07:21

Re: Something about msecval
 
2 Pierre-Marie Baty vbmenu_register("postmenu_4927", true);
You function (void SetSpeed (bot_t *pBot)) only for CS 1.5? Where weapon FAMAS, GALIL?


Pierre-Marie Baty 03-02-2004 10:17

Re: Something about msecval
 
right, it's not "my" function, really ; it's eLiTe's function (which he had in his TEAMbot). You'll have to figure out yourself what are the player's max speed when you are carrying a FAMAS or a GALIL.

But I suggest you rather use pBot->pEdict->v.maxspeed like KaCaT said.

Pierre-Marie Baty 03-02-2004 11:25

Re: Something about msecval
 
BTW, KaCaT, does pEdict->v.maxspeed also work for CS 1.5 ?

KaCaT 03-02-2004 15:02

Re: Something about msecval
 
No, it doesn't works for CS 1.5. The value it gives for bots in CS 1.5 always is 1000 8o

Pierre-Marie Baty 03-02-2004 18:44

Re: Something about msecval
 
then how about this instead:
Code:

void pfnSetClientMaxspeed (const edict_t *pEdict, float fNewMaxspeed)
{
  // update this client's max speed (Counter-Strike 1.5 doesn't do it right)
  ((edict_t *) pEdict)->v.maxspeed = fNewMaxspeed;
  (*g_engfuncs.pfnSetClientMaxspeed) (pEdict, fNewMaxspeed);
}

:)

strelok 06-02-2004 06:54

Re: Something about msecval
 
With a speed everything is all right. Thanks. :)
But the problem with freezing has remained. :(

strelok 08-02-2004 12:39

Re: Something about msecval
 
What value should be up to freeze time and what after?

Pierre-Marie Baty 08-02-2004 16:22

Re: Something about msecval
 
the bot's maxspeed should be kept at 0 before freeze time, and raised to the normal value (pBot->pEdict->v.maxspeed in CS 1.6 or f_max_speed passed in pfnSetClientMaxSpeed() in CS 1.5) immediately after it. But I'm not sure your problem comes from here...

Dysangel 30-05-2018 18:16

Re: Something about msecval
 
This is a long shot, but does anyone still have the TEAMbot source code? I would appreciate it if you could mail to me at nboxelite@hotmail.com

I am making multiplayer game in Unreal Engine and would like to use my old bot perception code as a reference, since I had spent a lot of time tweaking it to be fun to play against

I lost the original code a long time ago after a power surge destroyed my PC. Since then I have realised the importance of backups :p


All times are GMT +2. The time now is 19:18.

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