View Single Post
Re: Correct walk speed?
Old
  (#4)
KickBot
Member
 
Status: Offline
Posts: 17
Join Date: Apr 2004
Default Re: Correct walk speed? - 06-04-2004

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
{
	switch (s)
	{
		case BODYSPEED_STAND: 
			return 0.0f;
		case BODYSPEED_WALK:
			//Experiments on human player with CS1.5 gives these velocities:
			//Pistol			  Run:250  Walk:130
			//Knife			   Run:260  Walk:135
			//Kalash+Armor&Helmet Run:221  Walk:114   
			//so it seems the formula is linear and integer:
			//  Walk = (int)Run/2 + (int)(Run/50).
			return (float) (((int)flMaxSpeed)/2 + ((int)flMaxSpeed)/50);
		case BODYSPEED_RUN:
		default:
			return flMaxSpeed;
	}
}
(crap I use DevC++ ide indentation and had to redo it there by hand...)

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.
  
Reply With Quote