![]() |
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? |
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. |
Re: Something about msecval
PMB is right, This piece of code should not cause errors. I'm using it too.
|
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. |
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 ?
|
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.
|
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 |
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> |
Re: Something about msecval
@Cheeseh: Strelok is using Count Floyd's code, and CF obviously fixed this angle problems for quite a time already :)
|
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.
|
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] |
Re: Something about msecval
Quote:
|
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 ? |
Re: Something about msecval
Quote:
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? |
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.)
|
Re: Something about msecval
Quote:
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. |
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. |
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) |
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.
|
Re: Something about msecval
curious...
does it occur also if you set the mp_freezetime CVAR to 0 ? |
Re: Something about msecval
NO:) If mp_freezetime = 0.0 all is normal.
|
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.
|
Re: Something about msecval
max speed DURING the freeze time: cs1.5 = 1, cs1.6 = 320, AFTER it: cs1.5 = 250, cs1.6 = 320
|
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... |
Re: Something about msecval
Quote:
|
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 :)
|
Re: Something about msecval
I just get freaking nuts of CS 1.6 guys! Or should i say, get sick of this STEAM? Argh.
|
Re: Something about msecval
Quote:
Quote:
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. |
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.
|
Re: Something about msecval
i don't get it either, but if pEdict->v.maxspeed works i have said nothing ;)
|
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.
|
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? |
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. |
Re: Something about msecval
BTW, KaCaT, does pEdict->v.maxspeed also work for CS 1.5 ?
|
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
|
Re: Something about msecval
then how about this instead:
Code:
void pfnSetClientMaxspeed (const edict_t *pEdict, float fNewMaxspeed) |
Re: Something about msecval
With a speed everything is all right. Thanks. :)
But the problem with freezing has remained. :( |
Re: Something about msecval
What value should be up to freeze time and what after?
|
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...
|
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.