Help - Search - Members - Calendar
Full Version: Added some codes of AUX Power for BOT (Not perfect)
RCBot Forums > RCBot 2 for HL2 > Source
Salvax
___feb 25th 2007___
added: bot can randomly switch weapon (weapon picked up, pistol, grenade and SMG. and Be SURE in bot profile, weapon = default ).

improved: bot can sprint randomly (not ONLY attacking or under attack).

_____OLD LOG ______
added: bot can sprint.
added: bot can have secondary attack mode (SMG Grenade, AR2 Ball, Shotgun, S.L.A.M, Grenade).

You can download the latest modified source code and test only [HPB_bot2.dll] here:

rcbot2_test_only_feb25.rar (test map included, load test map:salvax, and tpye exec rcbot2 in console.)
http://www.sendspace.com/file/tyxlae

modified_rcbot2src_base_feb25.rar
http://www.sendspace.com/file/vodflz

You can also search "salvax" to check the modified source code. Thank You Again, Captain Cheeseh !!!


********************************************************************************
********
PLZ test it, Captain ! (U can downlaod below ,ALL latest modified source and DLL uploaded)

After the secondary attack code, i added some new codes of AUX Power for bot,(of cause my new code is based on bot button again, this time i think it 's not as good as i thought, because bot only use AUX power to rush when he wants to kill an enemy or he is under attack. I think let bot rushing is a random thing, so i need time to try if i can change the bot button thing to random bot action.

Now i bring u a small problem:

i think these code below make bot stand and jump on one point to shoot his enemy, would u plz adjust the time value so the bot can be standing there for a short time. then bot can take more time to use AUX power to rush and flank. (i tried a whole day to adjust the time value, but in vain)

bot.cpp

QUOTE
void CBot :: jump ()
{
if ( m_pButtons->canPressButton(IN_JUMP) )
{
m_pButtons->holdButton(IN_JUMP,0/* time to press*/,0.5/* hold time*/,0.5/*let go time*/);
// do the trademark jump & duck
m_pButtons->holdButton(IN_DUCK,0.2/* time to press*/,0.3/* hold time*/,0.5/*let go time*/);
}
}

void CBot :: duck ( bool hold )
{
if ( hold || m_pButtons->canPressButton(IN_DUCK) )
m_pButtons->holdButton(IN_DUCK,0.0/* time to press*/,1.0/* hold time*/,0.5/*let go time*/);
}


____________________________________________
Great many thx to Captain Cheeseh!!!

rcbot2_for_test_only_feb22.rar (*You can test secondary attack mode and AUX Power in the test MAP:salvax*)
http://www.sendspace.com/file/ufsh77

rcbot2_modified_source.rar (*You can search string "salvax" to see the added codes.*)
http://www.sendspace.com/file/a5uhn0
Cheeseh
The bot only moves if it has a valid path, To obtain a valid path the bot must used the CFindPathTask task and find a waypoint or entity. When it reaches its goal it will stop until it can obtain a new CFindPathTask, which will update the bots path and the bot will start moving around again.

For example before attacking a bot can find a path (using CFindPathTask) to a good spot to attack the enemy from. It will update the bots new route/path and then CAttackTask will take over, because the route is valid, whilst moving towards that route the bot will attack. But when the bot reaches that spot where he wanted to go first, he will stop. So he needs a new path if you want it to keep moving. Unfortunately I don't know if I have implemented any non-interrupt methods for CFindPathTask tasks to run before a path has been found.
Salvax
if i delet the codes above, what would happen ? BOt would not attack , but only run around ? blink.gif

BTW...how do u make bot run without bot button , pathfinding ?? I wanna to go in deeper and try if i can add random action for bot using AUX Power to rush ?
Cheeseh
If you remove jump and duck codes, this will do nothing except stop bots from being able to jump and duck. The movement is done in the WaypointNavigator

notice...
CODE

----------------------
CWaypointNavigator::updatePosition()

..
    if ( m_iCurrentWaypoint == -1 ) // invalid (Or reached goal!)
    {
        m_pBot->stopMoving();    // invalidates MoveTo
        return;
    }
..

m_pBot->setMoveTo(vWptOrigin); // validates MoveTo

-------------------
CODE

void CBot :: doMove ()
{
    // moving somewhere?
    if ( moveToIsValid () )
        {
           ....
        }
...
Salvax
THX, hmmm if i don't like the bot to stop, can i change the highlighted code below stopMoving(); to: findEnemy(); ?

bot.cpp

QUOTE
if ( m_pNavigator->hasNextPoint() )
{
m_pNavigator->updatePosition();
}
else
stopMoving();



PS:

but how can i make bots to rush with AUX Power without the bot button thing ? these speed codes? :

bot.cpp

QUOTE

cmd.forwardmove = m_fForwardSpeed;
cmd.sidemove = m_fSideSpeed;
cmd.upmove = m_fUpSpeed;
Cheeseh
no doing that removes the essence of game programming tongue.gif (and it wouldn't make sense)

findEnemy only updates the bots m_pEnemy it doesn't instantly make a bot run around for an enemy and shoot them, no its much more complex and requires several stages (as everything is split into tasks, these tasks get read every frame and do not complete until several frames or seconds have passed).



if you want them to use the AUX power Sprint, they need to press the sprint button, doing so any other way is considered a 'hack'
Salvax
yep, i did add the AUX power Sprint key for bot, but bot sprints only when he is under attack or attacking enemy, should i modify them , plz give me ur advice.

current code: - bot.cpp

QUOTE

void CBot :: primaryAttack ()
{
float fLetGoTime = 0.15;

// not currently in "letting go" stage?
if ( m_pButtons->canPressButton(IN_ATTACK) )
{
m_pButtons->holdButton
(
IN_ATTACK,
0/* reaction time? (time to press)*/,
0.12/* hold time*/,
fLetGoTime/*let go time*/
);
}
}

....
...
..
.

void CBot :: speed () // Speed for BOT by Salvax
{
if ( m_pButtons->canPressButton(IN_SPEED) )
m_pButtons->holdButton(IN_SPEED,0/* time to press*/,0.25/* hold time*/,0.15/*let go time*/); // Speed for BOT by Salvax
m_pButtons->holdButton(IN_FORWARD,0/* time to press*/,0.25/* hold time*/,0.15/*let go time*/); // Speed for BOT by Salvax
}
Cheeseh
QUOTE(Salvax @ Feb 23 2007, 01:40 PM) *

yep, i did add the AUX power Sprint key for bot, but bot sprints only when he is under attack or attacking enemy, should i modify them , plz give me ur advice.

current code: - bot.cpp


just put "sprint" in the FindPath task or in the WaypointNavigator::updateposition, if m_pLastEnemy is not null and nearby, then hold sprint
Salvax
donot know if it right, plz check, thx. and by the way, which is better , FindPath task or in the WaypointNavigator::updateposition ?

**************************************
bot_waypoint.cpp
____________________________________________

QUOTE
void CWaypointNavigator :: updatePosition ()
{
static Vector vWptOrigin;

if ( m_iCurrentWaypoint == -1 ) // invalid
{
m_pBot->stopMoving();
return;
}

CWaypoint *pWaypoint = CWaypoints::getWaypoint(m_iCurrentWaypoint);

if ( pWaypoint == NULL )
return;

vWptOrigin = pWaypoint->getOrigin();

if ( pWaypoint->touched(m_pBot->getOrigin()) )
{
pWaypoint->botTouch(m_pBot);

if ( m_currentRoute.IsEmpty() ) // reached goal!!
{
m_iCurrentWaypoint = -1;

if ( m_pBot->getSchedule()->hasSchedule(SCHED_RUN_FOR_COVER) )
m_pBot->reachedCoverSpot();
}
else
{
m_iCurrentWaypoint = m_currentRoute.Pop();

if ( m_iCurrentWaypoint != -1 )
{
vWptOrigin = CWaypoints::getWaypoint(m_iCurrentWaypoint)->getOrigin();
}
}
}

if ( pWaypoint->hasFlag(CWaypointTypes::W_FL_CROUCH) )
{
m_pBot->duck(true);
}

if ( (m_pLastEnemy != NULL) && (currentWaypoint() == -1) ) // Sprint for BOT by Salvax
{
m_pButtons->speed();
}


m_pBot->setMoveTo(vWptOrigin);
}


**************************************************
bot_task.cpp
__________________________________________________
QUOTE
void CFindPathTask :: init ()
{
m_bNoInterruptions = false;
m_bGetPassedVector = false;
m_iInt = 0;

//setFailInterrupt(CONDITION_SEE_CUR_ENEMY);
}

void CFindPathTask :: execute ( CBot *pBot, CBotSchedule *pSchedule )
{
bool bFail = false;

if ( pSchedule->hasPassVector() )
{
m_vVector = pSchedule->passedVector();
pSchedule->clearPass();
}

if ( (m_iInt == 0) || (m_iInt == 1) )
{
if ( pBot->getNavigator()->workRoute(pBot->getOrigin(),m_vVector,&bFail,(m_iInt==0),m_bNoInterruptions) )
m_iInt = 2;
else
m_iInt = 1;
}

if ( bFail )
fail();
else if ( m_iInt == 2 )
{
if ( m_bNoInterruptions )
m_pButtons->speed(); // Sprint for BOT by Salvax
complete(); // ~fin~

if ( !pBot->getNavigator()->hasNextPoint() )
m_pButtons->speed(); // Sprint for BOT by Salvax
complete(); // reached goal
else
{
if ( pBot->moveFailed() )
fail();

// running path
pBot->setLookAtTask(LOOK_WAYPOINT);
}
}
}


PS:I think it is far more to go sad.gif
Cheeseh
inside the waypoint navigator is probably better,

and you would be better changing the CFindPathTask code back, you've messed it up tongue.gif Because you didn't encapsulate the if statements with two or more lines in curly brackets.
Salvax
ok, we choose navigator waypoint, but i got some errors about undifined m_pButtons thing and SPEED sad.gif
Cheeseh
QUOTE(Salvax @ Feb 24 2007, 02:07 PM) *

ok, we choose navigator waypoint, but i got some errors about undifined m_pButtons thing and SPEED sad.gif

shouldn't it be m_pBot->speed() , not buttons ??? Its in your code.
Salvax
QUOTE(Cheeseh @ Feb 24 2007, 02:15 PM) *

shouldn't it be m_pBot->speed() , not buttons ??? Its in your code.


OMG ! What a dumm I am !!! THX A LOT !!!

PS:I delet
if ( (m_pLastEnemy != NULL) && (currentWaypoint() == -1) ) , and it works 100% now !!!!!!!

Now BOT would like to sprint not only when he is attacking or being attacked !!!! THX , Captain, now the work is tweaking the time parameter in SPEED:

QUOTE
void CBot :: speed ()
{
if ( m_pButtons->canPressButton(IN_SPEED) )
m_pButtons->holdButton(IN_SPEED,0/* time to press*/,0.25/* hold time*/,0.15/*let go time*/); // Speed for BOT by Salvax

would u give me ur advice ? I think maybe the hold time should be shorter, what do u think , Captain ?
Cheeseh
it doesn't matter, it that function is being called every frame, then the button is held until the statement is unreachable, which in your code it isn't.
SuperHebbe
___feb 25th 2007___

Hi.. I'm running your version on my server now and it works very well biggrin.gif good job Salvax...
But what happens to your code when the cheesy dude tongue.gif releases his version? Do you guys fo it togehter or what?

Salvax: Could you also please make the bots change to pistol, crowbare, stunstick or crossbow when they are under water?? Seems like they don't wanna get up lol drowning like hell... So at least give them a chance to shoot someone before they drown hehe...

Thanks for keeping this mod alive Salvax and the cheesy dude tongue.gif biggrin.gif
Salvax
just thank Captain Cheeseh, i did nothing smile.gif
SuperHebbe
Well... Running this version might be the cause of server crashing with this error: ED Aloc: No Free Edicts
Tested on 2 servers, and when we go back to the cheesy dudes version it works fine again... Maybe there is something here you can look at: http://articles.thewavelength.net/444

A quote from this article: "Firstly, if there was no delay, as the use key is held down for about a second the code will loop, dropping and picking up weapons. This will result in a not enough edicts error and crash the game"

Thanks to [EYE] Loki for finding this article smile.gif

Keep up the work biggrin.gif
Loki
No thoughts yet Salvax?? - apart from the "frequent" crashes your version looked very promising, some good features.... be nice to hear what you think regarding the crashes. Seemed like most of the crashes I saw occured at the point a new player joined and a BOT dropped off?

For now I'm back to Cheeseh's last version which has crashed only once in 5 days - same error reported "ED Aloc: No Free Edicts" - put that one down to limitations with Valves code - these BOTs are maybe never going to be perfect in HL2DM?? but it's damned near close enough.

Great Job Cheeseh and good luck Salvax.
Salvax
thx for ur feedback, for the crashing problem ,i recommend the Deathmatch not Team DeathMatch.

and since i'v added some more random thing, u should know...

i would pay more attention to the problem . ph34r.gif
SuperHebbe
QUOTE(Salvax @ Mar 31 2007, 01:13 PM) *

thx for ur feedback, for the crashing problem ,i recommend the Deathmatch not Team DeathMatch.

and since i'v added some more random thing, u should know...

i would pay more attention to the problem . ph34r.gif


I never use team deathmatch, and I know Loki dosen't either...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.