![]() |
Correct walk speed?
I have noticed that simply deviding the current movespeed by 2 does NOT give you the actual walk speed used by CS. I can even hear my bots walk while they move slower , and they say in debug console that they are 'walking'.
Currently i have this: Code:
// walk only when NOT holding duck (is same as walking, combination makes bot super slow) |
Re: Correct walk speed?
I am using something similar but I always suspected it was wrong too... glad to be certain of it at last.
What you can do is to use PMTools to print your player's velocity when you're running and when you're walking, using different weapons, and see if one is always the half of the other (and if not, what fraction of it). In order to keep pressing the forward key when you're in the console, enter "+forward" in the console. When you want to stop going forward, enter "-forward". Same for walking. You can use this to check your player's velocity while in movement. *edit* P.S: be sure to do this when you're on a flat ground. |
Re: Correct walk speed?
I have run a little test:
Pistol/Knife: Running speed = 250 Walking = 130 M4A1 Running speed = 230 Walking = 125 MP5 Running speed = 250 Walking = 130 There is no simple 'devide to' formula in this one. You could do with the MP5 and such , devide by 1.913 or something, but then it would not match with the M4A1 I bet there are different walk speeds for all weapons. |
Re: Correct walk speed?
When I tried to make a bot for cs1.5 I got into this problem also.
I did experiments with the player and came up with this: Code:
float ABotBody::BodySpeed2RealSpeed( BODY_SPEED s, float flMaxSpeed ) const It semeed like a good approximation but did not investigate much. IIRC casting to int before the divisions was important and more accurate than using floats. The thing is you have to always keep track of the actual max speed (passed as a parameter here flMaxSpeed). I don't remember if intercepting engine's pfnSetClientMaxspeed always worked or not. Thanks I don't have this kind of variable maxspeed problems in IOS :) Hope this helps. |
Re: Correct walk speed?
i have tried your code, and it also lets the bots walk slow. But the strange thing is, you can still hear this player walking. I think its a bug in CS or something. THe bots 'walk hearing speed' is faster then the actual walk animation.
|
Re: Correct walk speed?
What i did is this.
I checked out which speed the game dll assigns to players when, walking, croucing, proneing, running, walking slow Then i used those speeds to give to the bots. So instead of deviding the max_speeds. I assign speeds the game.dll would do. That way they move the same speed as clients do And the footstep sounds will be fixed then also. Cos the game.dll checks for client move speed and sets evironmental sounds to the player walking. running. etc etc. |
Re: Correct walk speed?
Well the safest way would be to record all speeds for the player in a big table to have a relation [equipment] -> {speeds}, because in CS speed depends on your equipment, so you'll have to measure every combination possible...
Stefan IIRC you also have to set the proper buttons pushed or released like a player would do (IN_RUN etc...). Just hang a minute I'll see if I can resurect my bot and check the sound thing under CS 1.5... Edit: Ok. The bots are walking and don't make walking sound and are playing the proper animation. At least with the starting equipment. Maybe my trick doesn't work for all kind of equipment or the version of CS you are running, dunno. In addition I have the following code to make sure the right walk buttons are pressed, just before sending the orders to the engine: Code:
if (m_IdealSpeed == BODYSPEED_WALK) m_ActButtons &= (~IN_RUN); |
Re: Correct walk speed?
In CS 1.5 normally the players would recieve their max speed from the game dll. In CS 1.6 it seems not to work that well anymore. I also found some glitches with health updates too. Anyway, i am going to try this 'IN_RUN' thingy and let you know if it worked.
|
Re: Correct walk speed?
i have this code:
Code:
// walk only when NOT holding duck (is same as walking, combination makes bot super slow) |
Re: Correct walk speed?
Quote:
|
Re: Correct walk speed?
I don't know that from the top of my head.
I'll post the messages later today. |
Re: Correct walk speed?
Code:
void pfnSetClientMaxspeed(const edict_t *pEdict, float fNewMaxspeed) Although TOD is spamming the system continiosly with the pfnSetClientMaxspeed, DOD only sends it when the clients speed changes. In dod the speed also depends what gun and if the gun is deployed. In that case there are more speeds to recorded for each class and gun. crouching etc etc. ================= edit. I recorded only the main speeds like when a client crouches. It may varie a little but when the speed is below a certain level. The game dll knows it's slow enuf to stop footstep sounds. Or when the speed is low enuf the game knows it can't move because it is like zoomed or deployed. However im not sure fo CS code. (as i don't code for cs) |
Re: Correct walk speed?
There is a CVAR named cl_movespeedkey which influences the speed while you walk. It defaults to 0.520 which might be a faktor to the normal speed.
|
Re: Correct walk speed?
@Stefan: never forget your bot is a SERVER-SIDE bot ! Hence you can completely drop off the hooking for Health, Battery, WeapPickup messages and such, because you have direct access to them whenever you want in pEdict->v.health, pEdict->v.armorvalue and pEdict->v.weapons respectively !
In CS 1.6, the max speed is available in pEdict->v.maxspeed In CS 1.5, the max speed was sent to the clients through a pfnSetClientMaxSpeed() call. Hence the fix is to always look in pEdict->v.maxspeed, and use pfnSetClientMaxSpeed() like this: Code:
void SetClientMaxspeed (const edict_t *pEdict, float fNewMaxspeed) |
Re: Correct walk speed?
omg. You are right. I always forget that when coding for CS 1.6. I got so used to hooking and such, i forgot its now the other way around. I checked my code and saw that i do not use direct accessing when running RB for CS 1.6. I will fix them immidiatly and then hope it works :) i'll let ya know.
|
Re: Correct walk speed?
yeeeeeeeeeeeeeeeeeehaw, fixed! This is l33t. THanks guys!
ow, did i already mentioned it worked? :P ;) |
Re: Correct walk speed?
Quote:
|
Re: Correct walk speed?
Good point indeed Whistler ! :)
|
Re: Correct walk speed?
I've found this in Q1 engine code:
Code:
if (in_speed.state & 1) Code:
cvar_t cl_movespeedkey = {"cl_movespeedkey","2.0"}; In CS the default value of cl_movespeedkey CVAR is usually 0.52, but the plain HL is 0.3. For each MOD you can type "cl_movespeedkey" in the console and you'll get the value. Note you can't use CVAR_GET_FLOAT("cl_movespeedkey") in the bot code because this CVAR is client-side. |
Re: Correct walk speed?
aha, so that would mean:
Code:
if (pEdict->v.button & IN_RUN) *edit* I'm dumb as f*ck sometimes, I didn't read Whistler's post until the end. DOH! Okay so that would need a #define for each MOD the bot supports, or perhaps a bot config file setting then. Gwaaah. |
Re: Correct walk speed?
Quote:
|
All times are GMT +2. The time now is 11:04. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.