|
Metamod and metamod plugins Plugins and improvements for the metamod server-side mod
|
|
Guest
|
Beginner question: Getting bots to spawn -
24-03-2004
Hi everyone,
I'm attempting to write a metamod CounterStrike bot "from scratch" (but using HPB as a reference) for Steam CS 1.6, but I'm having some trouble getting it to actually appear in world. My bot connects to the server just fine (in an almost indentical manner to HPB), but I never actually see it. I'm assuming this is because the bot is stuck at a team/model/... selection menu (does this sound right?), but the code I wrote to handle those messages never seems to get called.
I'm overriding pfnMessageBegin and, since my menu selections didn't seem to be happening properly, just logged the message ids that were sent to my bot when it was created. I got the following IDs:
111
84
98
101
Interestingly, 84 seems to be sent more times for each additional bot I add to the world: the first bot gets it once, the second twice, etc.
I know that there were some weirdnesses introduced by the move to steam, but can someone clarify what might be going on here, and maybe offer some advice on how to get my bots to appear? Thanks a lot for the help!
-JB
|
|
|
|
|
Roi de France
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
|
Re: Beginner question: Getting bots to spawn -
24-03-2004
Don't use the message IDs like botman does in the HPB_bot: metamod provides very handy facilities to handle network messages by name :
GET_USER_MSG_ID (PLID, "MessageName", NULL) will return the ID for the message MessageName, and
GET_USER_MSG_NAME (PLID, id, NULL) will return the name in all letters for a particular message id.
Here's a typical metamod pfnMessageBegin function:
Code:
if (mod_id == VALVE_DLL)
{
// if you wanted to print out what type of message you are receiving, you would do a:
//SERVER_PRINT (GET_USER_MSG_NAME (PLID, msg_type, NULL));
// ... and it would print the message name to the console
// normal pfnMessageBegin stuff follows...
if (msg_type == GET_USER_MSG_ID (PLID, "WeaponList", NULL))
botMsgFunction = BotClient_Valve_WeaponList;
else if (msg_type == GET_USER_MSG_ID (PLID, "CurWeapon", NULL))
botMsgFunction = BotClient_Valve_CurrentWeapon;
else if (msg_type == GET_USER_MSG_ID (PLID, "AmmoX", NULL))
botMsgFunction = BotClient_Valve_AmmoX;
else if (msg_type == GET_USER_MSG_ID (PLID, "AmmoPickup", NULL))
botMsgFunction = BotClient_Valve_AmmoPickup;
else if (msg_type == GET_USER_MSG_ID (PLID, "WeapPickup", NULL))
botMsgFunction = BotClient_Valve_WeaponPickup;
else if (msg_type == GET_USER_MSG_ID (PLID, "ItemPickup", NULL))
botMsgFunction = BotClient_Valve_ItemPickup;
else if (msg_type == GET_USER_MSG_ID (PLID, "Health", NULL))
botMsgFunction = BotClient_Valve_Health;
else if (msg_type == GET_USER_MSG_ID (PLID, "Battery", NULL))
botMsgFunction = BotClient_Valve_Battery;
else if (msg_type == GET_USER_MSG_ID (PLID, "Damage", NULL))
botMsgFunction = BotClient_Valve_Damage;
else if (msg_type == GET_USER_MSG_ID (PLID, "ScreenFade", NULL))
botMsgFunction = BotClient_Valve_ScreenFade;
}
else if (mod_id == TFC_DLL)
{
// tfc code follows...
Have you looked at the latest HPB_bot source code, the one that has been ported to metamod ?
RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
|
|
|
|
|
Guest
|
Re: Beginner question: Getting bots to spawn -
24-03-2004
Thanks for the reply Pierre-Marie. I'm actually basing my code on the metamod port of the HPB bot, so I'm already doing something almost identical to the code you posted here. I didn't know about GET_USER_MSG_NAME(..) though, which is very useful!
I tried printing the actual names of the messages being sent when I add my bot, and got the following:
NVGToggle
ScoreAttrib
ScreenFade
RoundTime
... still no VGUI. Does this look like what you'd expect for a newly added bot that has no menu-handling capabilities? Where are the menu messages? Help!
-JB
|
|
|
|
|
Roi de France
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
|
Re: Beginner question: Getting bots to spawn -
24-03-2004
Could you post your pfnMessageBegin function here ?
RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
|
|
|
|
|
Guest
|
Re: Beginner question: Getting bots to spawn -
24-03-2004
Sure, here it is:
Code:
void pfnMessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) {
int index = -1;
LOG_CONSOLE(PLID, "Message \"%s\"sent to ID %d.", GET_USER_MSG_NAME(PLID, msg_type, NULL), msg_dest);
if (ed) {
// Get the index of the bot this message is meant for (if any)
index = UTIL_GetBotIndex(ed);
// If this message is meant for a bot, index != -1
if (index != -1) {
botMsgIndex = index;
if (msg_type == GET_USER_MSG_ID (PLID, "VGUIMenu", NULL)) {
LOG_CONSOLE(PLID, "VGUI message; setting botMsgFunction\n");
botMsgFunction = BotClient_VGUI;
}
else if (msg_type == GET_USER_MSG_ID (PLID, "ShowMenu", NULL))
LOG_CONSOLE(PLID, "ShowMenu message intercepted.\n"); //botMsgFunction = BotClient_CS_ShowMenu;
else if (msg_type == GET_USER_MSG_ID (PLID, "WeaponList", NULL)) // Tells us about what weapons we (have? can get?)
LOG_CONSOLE(PLID, "WeaponList message intercepted.\n"); //botMsgFunction = BotClient_CS_WeaponList;
else if (msg_type == GET_USER_MSG_ID (PLID, "CurWeapon", NULL))
LOG_CONSOLE(PLID, "CurWeapon message intercepted.\n"); //botMsgFunction = BotClient_CS_CurrentWeapon;
else if (msg_type == GET_USER_MSG_ID (PLID, "AmmoX", NULL))
LOG_CONSOLE(PLID, "AmmoX message intercepted.\n"); //botMsgFunction = BotClient_CS_AmmoX;
else if (msg_type == GET_USER_MSG_ID (PLID, "WeapPickup", NULL))
LOG_CONSOLE(PLID, "WeapPickup message intercepted.\n"); //botMsgFunction = BotClient_CS_WeaponPickup;
else if (msg_type == GET_USER_MSG_ID (PLID, "AmmoPickup", NULL))
LOG_CONSOLE(PLID, "AmmoPickup message intercepted.\n"); //botMsgFunction = BotClient_CS_AmmoPickup;
else if (msg_type == GET_USER_MSG_ID (PLID, "ItemPickup", NULL))
LOG_CONSOLE(PLID, "ItemPickup message intercepted.\n"); //botMsgFunction = BotClient_CS_ItemPickup;
else if (msg_type == GET_USER_MSG_ID (PLID, "Health", NULL))
LOG_CONSOLE(PLID, "Health message intercepted.\n"); //botMsgFunction = BotClient_CS_Health;
else if (msg_type == GET_USER_MSG_ID (PLID, "Battery", NULL))
LOG_CONSOLE(PLID, "Battery message intercepted.\n"); //botMsgFunction = BotClient_CS_Battery;
else if (msg_type == GET_USER_MSG_ID (PLID, "Damage", NULL))
LOG_CONSOLE(PLID, "Damage message intercepted.\n"); //botMsgFunction = BotClient_CS_Damage;
else if (msg_type == GET_USER_MSG_ID (PLID, "Money", NULL))
LOG_CONSOLE(PLID, "Money message intercepted.\n"); //botMsgFunction = BotClient_CS_Money;
else if (msg_type == GET_USER_MSG_ID (PLID, "ScreenFade", NULL))
LOG_CONSOLE(PLID, "ScreenFade message intercepted.\n"); //botMsgFunction = BotClient_CS_ScreenFade;
}
}
RETURN_META(MRES_IGNORED);
}
Anything looking blatently wrong here? Also, I'm using CS 1.6- have the procedures for selecting teams and buying weapons changed significantly?
Thanks again.
-JB
|
|
|
|
|
Guest
|
Re: Beginner question: Getting bots to spawn -
24-03-2004
Oops, one more question: is there a comprehensive list of the message strings that can be sent in counterstrike?
-JB
|
|
|
|
|
Roi de France
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
|
Re: Beginner question: Getting bots to spawn -
25-03-2004
All network messages are registered by the game DLL to the engine when the game starts. The function to catch to get a list of the registered network messages if pfnRegUserMsg.
Here's a list of network messages in CS 1.5 (I keep them in a config file for my bot):
Code:
# RACC - Engine messages configuration file
#
# This file contains information needed by the game to engine interface
# about the network messages used in the game. The syntax is explicit.
#
# It is recommended to sort the messages by alphabetical name, in order
# to speedup the queries in the database later in game. It would be
# definitely best to sort the messages by frequency, but do this only
# if you know well which are the messages that are the most often sent
# over the network in this game.
#
# Any void or sharp-prepended line will be ignored.
#
# <msg name> <id> <size>
# Default Half-Life engine messages
TempEntity 23 -1
Intermission 30 -1
CDTrack 32 -1
WeaponAnim 35 -1
RoomType 37 -1
Director 51 -1
# MOD-specific custom messages
VoiceMask 64 8
ReqState 65 0
CurWeapon 66 3
Geiger 67 1
Flashlight 68 2
FlashBat 69 1
Health 70 1
Damage 71 12
Battery 72 2
Train 73 1
HudText 74 -1
SayText 75 -1
TextMsg 76 -1
WeaponList 77 -1
ResetHUD 78 0
InitHUD 79 0
ViewMode 80 0
CheckModels 81 0
GameTitle 82 1
DeathMsg 83 -1
ScoreAttrib 84 2
ScoreInfo 85 9
TeamInfo 86 -1
TeamScore 87 -1
GameMode 88 1
MOTD 89 -1
ServerName 90 -1
AmmoPickup 91 2
WeapPickup 92 1
ItemPickup 93 -1
HideWeapon 94 1
SetFOV 95 1
ShowMenu 96 -1
ScreenShake 97 6
ScreenFade 98 10
AmmoX 99 2
SendAudio 100 -1
RoundTime 101 2
Money 102 5
ArmorType 103 1
BlinkAcct 104 1
StatusValue 105 -1
StatusText 106 -1
StatusIcon 107 -1
BarTime 108 2
ReloadSound 109 2
Crosshair 110 1
NVGToggle 111 1
Radar 112 7
Spectator 113 2
VGUIMenu 114 -1
AllowSpec 115 1
BombDrop 116 6
BombPickup 117 0
ClCorpse 118 -1
HostagePos 119 8
HostageK 120 1
*edit* I forgot to say that I don't see anything wrong with your code... is it that you don't see any of your LOG_CONSOLE messages ?
instead of doing if (ed), try doing if (!FNullEnt (ed))... but it should work nonetheless...
RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
Last edited by Pierre-Marie Baty; 25-03-2004 at 00:19..
|
|
|
|
|
Guest
|
Re: Beginner question: Getting bots to spawn -
25-03-2004
Thanks for the list. Any ideas on why my bot isn't actually getting any VGUI messages? I added a LOG_CONSOLE statement to the HPB bot, and noticed that it seems to be getting many more messages (and more appropriate ones like VGUI as well) than mine do. I know it's tough to debug based on so little info, but if you have any ideas I'd love to hear them. What should happen after my bot has connected to the server?
|
|
|
|
|
Roi de France
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
|
Re: Beginner question: Getting bots to spawn -
25-03-2004
with this line
Code:
LOG_CONSOLE(PLID, "Message \"%s\"sent to ID %d.", GET_USER_MSG_NAME(PLID, msg_type, NULL), msg_dest);
, you should be catching all the network messages the game is sending, INCLUDING the VGUI messages it should send to your bot. If these messages aren't sent, that's the bot incorrectly connected the server (check your BotCreate() function, because Counter-Strike needs specific stuff in there). If it displays these messages but you can't catch them later on in the same function, there's perhaps a problem with your UTIL_GetBotIndex().
RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
|
|
|
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
HTML code is Off
|
|
|
Powered by vBulletin® Version 3.8.2 Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com
|
|