.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Best msec val ever!!!
Old
  (#1)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,620
Join Date: Jul 2004
Location: Bulgaria
Default Best msec val ever!!! - 25-04-2006

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.

Last edited by The Storm; 12-08-2009 at 13:17..
  
Reply With Quote
Re: Best msec val ever!!!
Old
  (#2)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,620
Join Date: Jul 2004
Location: Bulgaria
Default Re: Best msec val ever!!! - 27-04-2006

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.
  
Reply With Quote
Re: Best msec val ever!!!
Old
  (#3)
Immortal_BLG
Member
 
Status: Offline
Posts: 171
Join Date: Nov 2007
Location: Russian Federation
Default Re: Best msec val ever!!! - 12-08-2009

Hello, I apologise that 3 years did not write, 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!

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
  
Reply With Quote
Re: Best msec val ever!!!
Old
  (#4)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,620
Join Date: Jul 2004
Location: Bulgaria
Default Re: Best msec val ever!!! - 12-08-2009

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.
  
Reply With Quote
Re: Best msec val ever!!!
Old
  (#5)
Immortal_BLG
Member
 
Status: Offline
Posts: 171
Join Date: Nov 2007
Location: Russian Federation
Default Re: Best msec val ever!!! - 12-08-2009

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....

Last edited by Immortal_BLG; 12-08-2009 at 13:46..
  
Reply With Quote
Re: Best msec val ever!!!
Old
  (#6)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,620
Join Date: Jul 2004
Location: Bulgaria
Default Re: Best msec val ever!!! - 12-08-2009

In the times I played around, the ppmove pointer was NULL in dedicated server, thats way maybe your bot crashes...
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com