newOak->client = gi.TagMalloc(sizeof(gclient_t), TAG_GAME);
bot->client = gi.TagMalloc(sizeof(gclient_t), TAG_GAME); //sets bot client value so it can be used
I cannot findnewOak->client = gi.TagMalloc(sizeof(gclient_t), TAG_GAME);anywhere in the linked original sources you showed in your first post. It is an error to do this anyway.
Quote from: QwazyWabbit on August 07, 2009, 08:23:42 AMI cannot findnewOak->client = gi.TagMalloc(sizeof(gclient_t), TAG_GAME);anywhere in the linked original sources you showed in your first post. It is an error to do this anyway.Interesting. This is just an aside, as I've never written a Q2 bot. But if I wanted a bot that 'pretended' to be a real client (like the Q3 arena bots do, for example), my first instinct would have been to make it a real client, so it would show up on the scoreboard, participate in death obituary messages, etc. (Then I imagined adding some flag, similar to the existing 'spectator' value, which would indicate this is really a bot client, so that certain logic that truly only applies to real clients could be conditionally avoided.)The hope would have been that making it a real client would require fewer special cases in the logic, than making it a monster. (But maybe that turns out not to be the case?)Anyway just rambling....
Alright!!! I just got it to display the bot's score on the scoreboard! I did it the way you suggested, QwazyWabbit- adding a pointer to the bot's entity in gclient_s. Thanks for the advice! I've been reading tutorials on C and Quake 2 for hours and hours the last couple of days and it's finally paid off. Now I just need to figure out how to display it's name on there. I'm guessing that when the scoreboard comes up, "client" gets replaced by the bot's name in the following line. Is that right? Com_sprintf (entry, sizeof(entry), "client %i %i %i %i %i %i ", x, y, sorted, cl->resp.score, cl->ping, (level.framenum - cl->resp.enterframe)/600);
Also another quick question. To get the address of the player's entity in the addbot function, I used the following. Is this the right way to do it, or is the player's entity ever at a point other than 0 in game.clients? gclient_t *player; player = &game.clients[0];Thanks again for the help. I can't believe I'm getting this stuff to work- it's like 10 years since I first wanted to be doing this kind of thing.
There is actually an error in the Oakbot tutorial. He defines void SP_Oak(void) but in the "oak" command he calls it with SP_Oak(ent); calling the spawn function that expects no arguments with an edict_t argument.