Mod development fun for source engine sdk 2013 multiplayer. piecemealing bits in at a time for the love of source
Posts | ||
---|---|---|
server bots repair | Post Reply | |
Thread Options | ||
|
Nov 28 2023 Anchor | |
Server-Side Bots Note:This has been tested in Source 2013 Multiplayer and it perfectly works.
A server-side bot is an entity that pretends to be a player, but is driven by AI instead. It usually derives from the game's main player class, and the majority of the game code can treat it like it's a regular player. ContentsConceptsThe primary responsibility of a server-side bot is to simulate user input for its player entity each server tick. To accomplish this, it fills in a While the ImplementationWay 1The SDK ships with a rudimentary sample bot. It runs in a straight line until it hits a wall, then it turns in a random direction. It is also very useful for testing player animations. To access the SDK bot, run Create a Mod from the SDK Launcher panel and choose Start a mod from scratch. Way 2If you picked Modify Half-Life 2 Multiplayer, you need to edit three files:
Comment out the
Comment out the Presumably the code block that follows needs to be edited: #ifdef DEBUG extern void Bot_RunAll(); Bot_RunAll(); #endif
Comment out the Presumably the code blocks that follow need to be edited: #ifdef DEBUG #include "hl2mp_bot_temp.h" #endif #ifdef DEBUG // Handler for the "bot" command. void Bot_f() { // Look at -count. int count = 1; count = clamp( count, 1, 16 ); int iTeam = TEAM_COMBINE; // Look at -frozen. bool bFrozen = false; // Ok, spawn all the bots. while ( --count >= 0 ) { BotPutInServer( bFrozen, iTeam ); } } ConCommand cc_Bot( "bot", Bot_f, "Add a bot.", FCVAR_CHEAT ); #endif Search for the following line ConCommand cc_Bot( "bot", Bot_f, "Add a bot.", FCVAR_CHEAT); and change to ConCommand cc_Bot( "bot", Bot_f, "Add a bot."/*, FCVAR_CHEAT */);
Note that when you make a server from with in visual studio, your limited to 2 players so only one bot will spawn. Con CommandsWhen you run the mod you've just created, the sample bot can be accessed with these commands:
You will find the sample bot code in The other interesting function in More Useful CodeThis code is by Tjoppen, and can be used with the bots, to respawn them, mess around with where it should go, this is YOUR TURN to learn. void Bot_HandleRespawn( CSDKBot *pBot, CUserCmd &cmd ) { // try hitting my buttons occasionally if ( !pBot->IsAlive() && random->RandomInt( 0, 100 ) > 80 ) { // flip button state cmd.butt 0, 1 ) == 0)?(cmd.buttons|IN_JUMP):0; } } Note that this code is already written in hl2dm_bot_temp.cpp if you're using HL2DM on Source Engine 2007 SDK. |
Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.