Welcome, Guest! Login | Register

Making Bots Join A Team [Print this Article]
Posted by: DOOManiac
Date posted: Feb 04 2005
User Rating: 4 out of 5.0
Number of views: 3043
Number of comments: 0
Description: Make the bots join whichever team you wish. So easy, even I can do it!
I finally did something own my own, so I figured I'd celebrate my progress with the SDK by sharing.

The bots added to the SDK are good for some debugging when you just need someone to stand there and be shot at, or if you just have some time to kill.

Note: Yes, I'm aware there is a bot_sendcmd command, however AFAIK that one execs on all bots, meaning it'd be tricky to have some bots on one team, some on another. That's what this tutorial is for...

Before we get started, this tutorial assumes you've already got teamplay working, and you're using the standard pPlayer->ChangeTeam() to change the team.

Okay, here we go:

First, open up sdk_bot_temp.cpp

Find BotAdd_f() function (around line 121)

Right below the part where it sets bFrozen based on a command line arg, add this:

 CODE (C++) 
    // Added by DOOManiac
    // Look at -team
    int team = TEAM_REBELS;
    team = FindEngineArgInt( "-team", 1 );

This code will look for a '-team' switch in the bot_add command and then get the argument for it. Pretty simple stuff.

Next, a few lines down find the call to BotPutInServer( bFrozen ) and change it to:
 CODE (C++) 
BotPutInServer( team, bFrozen );



Now find CBasePlayer *BotPutInServer( int team, bool bFrozen ) around line 84, and change its definition:
Change: CBasePlayer *BotPutInServer( int team, bool bFrozen )
To:
 CODE (C++) 
CBasePlayer *BotPutInServer( int team, bool bFrozen )


One last step, still in the BotPutInServer() function find the call to pPlayer->ChangeTeam( TEAM_UNASSIGNED ) and change it to:
 CODE (C++) 
pPlayer->ChangeTeam( team );


Now compile and run the game, and in the console type bot_add -team 1 or bot_add -team 2 (this could change depending on how your enumerations are set up)


That's it.

See? I told you it was easy.

Rate This Article
This article is currently rated: 4 out of 5.0 (1 Votes)

You have to register to rate this article.
User Comments

No User Comments

You must register to post a comment. If you have already registered, you must login.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 04 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005


Latest Comments
Spinning Corpses Simple Fix
Half-Life | Coding | Snippets
By: darkPhoenix | Sep 05 2008
 
Where do we go from here
General | News
By: MIFUNE | Jun 09 2008
 
The Input/Output system
Half-Life 2 | Level Design
By: nazitaco | Dec 23 2007
 
Where do we go from here
General | News
By: Rob_F | Nov 22 2007
 
Rescaling Half-Life
Half-Life | Coding | Shared Tutorials
By: christoph | Nov 12 2007
 
GameUI
Half-Life 2 | Coding | Client Side Tutorials
By: Evil_j | Oct 29 2007
 
3 State Zoom For Any Weapon
Half-Life 2 | Coding | Server Side Tutorials
By: Ennuified | Oct 18 2007
 
Storing weapons on ladder
Half-Life 2 | Coding | Snippets
By: cct | Sep 07 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: DarkNight | Aug 28 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: deedok | Aug 20 2007
 

Site Info
296 Approved Articless
5 Pending Articles
3940 Registered Members
0 People Online (16 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!