.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 2 SDK (http://forums.bots-united.com/forumdisplay.php?f=62)
-   -   RCBot 2 (http://forums.bots-united.com/showthread.php?t=5965)

redcomet 07-12-2006 11:47

RCBot 2
 
I got a bug in me to make at least a somewhat working bot program for a mod, so I downloaded RCBot 2. After I fixed the solution and everything I compiled and everything worked pretty well. However I noticed that the bots were moving really really fast and sometimes over shooting their way points and in some cases continually running around a loop point for a few seconds before moving on.

I tryed to lower their speed by modifying the runPlayMove function but found something weird.

I put a variable reporting mechanizm into the function to tell me how the bot is moving even though the function correctly sets the forward, side, etc, for some reason no mater what speed I set as max the bot would still move at the same speed in game.

So at a later point in time I changed my status code to this:

Code:

    CBotCmd cmdLast = m_pPlayerInfo->GetLastUserCommand();

    Msg( "Bot Data:\n" );
    Msg( "-----------------------\n");
    Msg( "Forward Speed: \"%f\"\n", cmdLast.forwardmove );
    Msg( "Side Speed: \"%f\"\n", cmdLast.sidemove );
    Msg( "Upward Speed: \"%f\"\n", cmdLast.upmove );
    Msg( "Buttons Down: \"%i\"\n", cmdLast.buttons );
    Msg( "Impulse: \"%i\"\n", cmdLast.impulse );
    Msg( "Weapon Select: \"%i\"\n", cmdLast.weaponselect );
    Msg( "\n\n\n\n" );

Notice the call to get last user command. What it does it go get the last bot command executed on the bot.

I got in game and was surprised to find that for some reason the values were sky rocketing at around 600 for forward at all times and upwards of 1700 for sideways at times..

Code:

Bot Data:
-----------------------
Forward Speed: "576.200317"
Side Speed: "1748.183472"
Upward Speed: "0.000000"
Buttons Down: "0"
Impulse: "0"
Weapon Select: "0"

As compared to the data collected on the command sent to the bot:

Code:

Bot Data:
-----------------------
Forward Speed: "-38.637028"
Side Speed: "10.352784"
Upward Speed: "0.000000"
Buttons Down: "0"
Impulse: "0"
Weapon Select: "0"

Also my bot does weird things such as sprint whenever possible and is in general out of control.
I was wondering if this is a project of the source sdk or something I have to do to the code. My files are pretty much straight rcbot code, all except for my own bot plugin for a different mod other then css or hl2dm.

I figure that there might be a conflict between the default dumb bot actions and what rc bot wants to do. For example, if you just create a dumb bot it will wondering around randomly, my theory is that what my bots are doing is a combination of that and rc bot's movements causing the really fast and random moveing.

So my question is how would I disable the dumb bot movement if that is indeed the problem.

Also, Cheeseh, I cannot register for your forums, otherwise I would have posted there. I fill out the form but do not receive a confirmation email.

Thanks for any help.

Cheeseh 10-12-2006 17:23

Re: RCBot 2
 
Hmm, I don't know what would cause that, first thing though is that I don't know if the Players LastCmd is updated for bots ? Do the LastCmd values always stay the same ?

Have you updated your source code to the latest SDK from valve? (SDK tools in steam -> Create Mod -> Source Code only) And extract source code over your current location of the Hl2 SDK, the same sdk where rcbot2 resides in (/utils) I usually do that to update the latest sdk each time, as it could be a version issue and that the RunPlayerMove() function is not correctly assigned to the correct memory address and the wrong function is getting called.

BTW I've changed my forum to use SMTP email so try registering again

redcomet 10-12-2006 19:02

Re: RCBot 2
 
No the last command values do change, and they change corresponding to what the bot is actually doing.

I downloaded the sdk brand new before I started working on this, maybe 2 days ago.

THanks for fixing the forums I will try to register again.

edit:
No go, my new account (redcomet) is not getting sent as email to my gmail account

Cheeseh 10-12-2006 20:27

Re: RCBot 2
 
The only things (I think) that would cause that is a "corrupted" playerinfo.h in the = operator of the CBotCmd class, causing the values to not copy correctly, OR The "cmd" is not passed correctly (which it should be) or cmd is corrupted, or something is altering memory where it shouldn't. Unless you've got or programs/plugins running with HL2?

you could also try adding:
m_pController->PostClientMessagesSent();
before the runplayermove call, It may or may not help since the bot framework given by valve has it.

Ps: I approved your account at the rcbot forums, and altered my SMTP settings again to see if it works next time

redcomet 10-12-2006 20:51

Re: RCBot 2
 
hm No that function did not fix it, I will have to start working with it again in a few days, I have finals this week..

Also I should mention I just tryed running them in hl2dm and they worked fine.

In dods they are skrewing up as well as my mod...

limpan 31-12-2006 02:10

Re: RCBot 2
 
Hi,
Iīm working on a mod to hl2dm with bots, itīs not a plugin, and I noticed this "default dumb bot actions" when I updated the SDK with the latest release.
After some headscratching Iīd come up with a solution to my problem.

When creating a bot you create an edict_t with something like this:
Code:

edict_t *pEdict = ::engine->CreateFakeClient(szName);
and with that I can get an CHL2MP_Player (but in a plugin you donīt have access to CBaseEntity :unsure:):
Code:

CHL2MP_Player*pPlayer=((CHL2MP_Player*)CBaseEntity::Instance(pEdict));
pPlayer->ClearFlags();
pPlayer->AddFlag( FL_CLIENT | FL_FAKECLIENT );

anyway I removed the flag FL_FAKECLIENT from the AddFlag() function and the dumb default behaviour was gone and my bots moved as they should.

The problem now was when I removed a bot from the server the game crashed on some flag checking function but that was fixed with adding the FL_FAKECLIENT flag right before the bot being removed.

This will probably not help a plugin if this is the problem and if it is then itīs up to valve to change their engine code that handles fakeclients


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

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