BIG EDIT: This work only for Listen servers. While coding I forgot that the bot is not a real client. Why worked? - Because the bots actually got the my msec val for them but when I runned Dedicated server guess what... - Crash. Anyway this was step forward to find something else in to the HLSDK code.
I found that
Code:
pmove->frametime = pmove->cmd.msec * 0.001;
In this way the game dll calculate the frametime from the real clients so we don't have msec in to the edit_t or gpGlobals but we have frametime in gbGlobals.
So in RunPlayerMove() for msec val use gpGlobals->frametime * 1000;
It work perfect and it seems that this is the best way to get the msec val. No need from special algoritms.
EDIT END.
Hi all,
Just making experiments all day I tryed too see how the real clients get their msec val. I found that in to the client dll but the same was defined in to the server dll too. So I tryed to use the same msec val that use the players for the bots and guess what. Amazing result. I'm directly getting the msec val from the engine. Now I will explain how all of you can use that for your bots.
You will need by the header "pm_defs.h" located in to the pm_shared folder of the standart SDK.
Ok now go to the your bot dll.cpp file, find where you had exported GetEntityAPI() and hook the function pfnPM_Move in it. For me it looks like that
Code:
pFunctionTable->pfnPM_Move = PM_Move;
Now create the your own PM_Move() in dll.cpp and make it to look like that.
Code:
void PM_Move ( struct playermove_s *ppmove, int server )
{
pmove = ppmove;
// If we are running metamod.
if (g_bIsMMPlugin)
RETURN_META(MRES_IGNORED);
(*other_gFunctionTable.pfnPM_Move) (ppmove, server);
}
"pmove" is defined as global varible in bot_globals.cpp in this way
Code:
playermove_t *pmove = NULL;
After that as you see in PM_Move we will give the information from "ppmove" to "pmove" to use it for the our needs.
Now find your RunPlayerMove() stuff and replace the msec tab with this
pmove->cmd.msec
For me it looks like that
Code:
g_engfuncs.pfnRunPlayerMove(pEdict, vecMoveAngles, pBot->f_move_speed,
pBot->f_sidemove_speed, 0, pEdict->v.button,
pEdict->v.impulse, pmove->cmd.msec);
Now recompile and fun.
Just to be sure that the real clients get their msec via "pmove" I just added in PM_Move() this - pmove->cmd.msec = 0;
and recompiled. When I selected a team I was in the air and I wasn't able to move.
Btw I think that in playermove_s there is very interesing stuff so play with it.