.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Best msec val ever!!! (http://forums.bots-united.com/showthread.php?t=5190)

The Storm 25-04-2006 00:12

Best msec val ever!!!
 
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. :)

The Storm 27-04-2006 20:49

Re: Best msec val ever!!!
 
Sinse some users can't understand what they must use the right way is:
gpGlobals->frametime / 0.001;
KWo told me that multiplication is faster so if you prefer you can use
gpGlobals->frametime * 1000;
Both are same. ;)

Immortal_BLG 12-08-2009 04:21

Re: Best msec val ever!!!
 
Hello, I apologise that 3 years did not write, :D but: thanks, you has opened my eyes on how it is possible to receive the pointer on structure playermove_s. I simply tried to adapt cheat function CanPenetrate() to know - whether a penetration wall or not, since IsShootableThruObstacle() not suit for me and for this purpose PM_TraceLine() function was necessary to me without which it will be impossible, but with the help ppmove I could carry out the conceived! :P

BTW I personally for a hook use not PM_Move(), but PM_Init() instead - itself personally tried differences in given pointers are not present + PM_Init() is called only once, instead PM_Move() is called constant....

And still I have a question: what it is better to use as msec value pmove->cmd.msec or gpGlobals->frametime * 1000???

Again sorry for bad english :(

The Storm 12-08-2009 12:16

Re: Best msec val ever!!!
 
As I mentioned above, the PM_ calls and pointers are only valid when you are running listen server, you can't use them in dedicated one, so the correct way in your case will be gpGlobals->frametime * 1000. Anyway there is other methods around too, in case you don't want to call the BotThink() function every frame. You can checkout the JKBotti code for other good implementation of the msec calculation.

Immortal_BLG 12-08-2009 12:35

Re: Best msec val ever!!!
 
Means there are no chances to get pmove pointer under dedicated server?

I tried to start dedicated server and PM_Init() is called :)
But my bot crushes on creating.... :0 need to work on it.... ;)

The Storm 12-08-2009 14:51

Re: Best msec val ever!!!
 
In the times I played around, the ppmove pointer was NULL in dedicated server, thats way maybe your bot crashes...


All times are GMT +2. The time now is 10:23.

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