Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Greenwood

Pages: [1] 2
1
Quake / Re: Question About Spawning a Bot in Quake 2
« on: August 21, 2009, 09:29:36 AM »
Thanks. But doesn't that mean that all your bots would have to have the same skin as the player? How could you get around that? You must be able to because the eraser bots, for example, all have different skins.

By the way, if you're coding bots, maybe you'd find the following page interesting. It's about the code for the bots in Quake 3, which has been made available to the public:

https://aigamedev.com/open/highlights/quake3-engine/

Maybe you could use some of that code for your bots. If not the hpb bot for half-life is also open source. Dunno if you're interested but I thought I'd mention that stuff in case.

2
Quake / Re: Question About Spawning a Bot in Quake 2
« on: August 20, 2009, 06:37:53 AM »
So if you have your bots as edict_t entities, rather than gclient_t entities, how do you go about changing their skins? Are you stuck with the default ones? I noticed that if you used something like this, you will get the male model and it's default skin.

Code: [Select]
newOak->model = "players/male/tris.md2";
newOak->s.modelindex = 255;
newOak->s.modelindex2 = 255;

But if changing skins is normally done via userinfo strings, how could you change the skin for a player model that's not a client?

Thanks.

3
Quake / Re: Question About Spawning a Bot in Quake 2
« on: August 12, 2009, 01:19:33 PM »
It is somewhat hard to do that because it would be dependant on the servers' files. You'd have to find his skin and model, and insert an _i in there.
Not sure though, because this might index the model, and you'd overflow pretty quickly if everyone had a different model.

-P

Thanks for the reply, but I'm not sure if I follow you here. I mean, say you wanted to output a particular portrait using sprintf, and it was one of the default male or female player skins. How would you go about finding the skin and model, and then outputting it?

As far as the portrait is concerned I believe it's based on the client's knowledge of the client index for each player in the scoreboard. From the client index, it looks up the portrait it has on file for that player's model and displays it from there.

I just want to get some fundamental things clarified in my mind here.

First, this might sound like a stupid question, but when you say "the client's knowledge of the client index for each player", do you mean that the client index is the appropriate element of game.clients for the required player? And then the knowledge is contained within that gclient_t entity?

Also, in the code, I've noticed that sometimes, the player will be referred to as an edict_t, and at other times, as a gclient_t. My understanding of this is that each player in the game has information about them contained in both an edict_t entity, and a gclient_t entity. Is this right? Again this might sound like a stupid question but I figured it would be worth getting this kind of thing understood properly.

Thanks for your help.

4
Quake / Re: Question About Spawning a Bot in Quake 2
« on: August 11, 2009, 03:04:07 PM »
The \ is the escape character in C. The same as in Perl or Ruby or half a dozen other languages (which are written in or owe their origins and practices to C). It means 'take the following character literally and insert it'. This is how you insert characters into a string when they would otherwise be interpreted as special tokens. We are using sprintf to format a string into a buffer that will be passed to the functions that transmit the contents of the string buffer to the client or will be used by the client as in string "...". This is actually the code that inserts:
string "    0 QwazyWabbitWOS     0    7"
into the buffer, putting spaces where there are no actual characters or digits to left or right justify the text as in my example above.

One thing I didn't show as part of the example of filling the string buffer for a custom scoreboard was the code to make it print a column header:

         strcpy(string,  "xv 0 yv 32 string2 \"Frags Player          Time Ping\" "
            "xv 0 yv 40 string2 \"----- --------------- ---- ----\" ");


We are formatting a string into a string argument for the sprintf function therefore if we want it to contain quotes we have to escape them so the C parser won't think the quoted text is ending. In C, if you want to print a quote character you have to do this:

printf("\"");

or for a double blackslash:

printf("\\\\");

The numbers are field widths. http://msdn.microsoft.com/en-us/library/56e442dc.aspx

The %-15s means it is left-aligned, 15 characters wide. This is the space occupied by the player name.

This is just an example of some of the fussing you have to do to get a C compiler to print a string in a particular way. They can't all be as easy as printf("Hello world!");

:)



Right. I didn't realise this was stuff that was used by C in general, or I would have looked it up.

I've been messing around a bit more with this, and have got it to display the bot's name, score, ping and time. Well, at least I know how to get it to display the bot's ping and time- right now I'm just displaying the player's as a temporary substitute. I'm doing the formatting in the standard Quake 2 way, to see if I can do that first. Obviously I would replace 32/ 64/ 72 etc. with %i and some variables, and then get it to calculate the positions for multiple scores.

sprintf (string + strlen(string),
            "xv 32 yv 64 string %s yv 72 string \"%-6s %i\" yv 80 string \"%-6s %i\" yv 88 string \"%-6s %i\" ",
            temp_bot_ent->bot_name, "Score:", temp_bot_ent->bot_score,
            "Ping:", cl->ping, "Time:", (level.framenum - cl->resp.enterframe)/600);

So yeah, thanks for your help with this, I seem to be making some progress. I'm wondering about the pictures though. Is there any way to get it to display your character's portrait on the scoreboard using sprintf? I noticed they do this to display the tag in the background, with tag just being set to "tag1" or "tag2":

Com_sprintf (entry, sizeof(entry),  "xv %i yv %i picn %s ",x+32, y, tag);

You may know this already but they're in the pics directory in pak0.pak- I know because I looked in there with QuArK. I can get Quake2 to display any of the other pictures in there in the game, just by replacing tag with whatever their name is. But is there any way to get it to display pictures or textures that aren't in that directory?

Thanks.

5
Quake / Re: Question About Spawning a Bot in Quake 2
« on: August 11, 2009, 02:41:27 AM »
Thanks.

There's something about the following I don't understand though.

sprintf(string + strlen(string),
               "xv 0 yv %d string \"%5d %-15s %4d %4d\" ",
               48 + i * 8,
               sortedscores,
               game.clients[sorted].pers.netname,
               (level.framenum - game.clients[sorted].resp.enterframe)/600,
               ping);

What's going on with the following part? "xv 0 yv %d string \"%5d %-15s %4d %4d\" ". It's almost like you've got three separate parameters- "xv 0 yv %d string \", then: %5d %-15s %4d %4d\, then: " ". Except there's no comma so it must only be one. Also I don't understand stuff like %5d. I understand that you use %d to output an int and %s to output a string but what do %5d or %-15s mean? Also what's the \ at the end for?

Thanks.

6
Quake / Re: Question About Spawning a Bot in Quake 2
« on: August 08, 2009, 03:16:58 PM »
Actually, when I said the following in the previous post, I meant to say that "client" gets replaced by the player's name, not the bot's name. Oops.

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);

I thought about that after I wrote it and realised that I wouldn't be outputting it in the same way as a client's name anyway. With that said, do you know what "client" in that line does exactly? I just tried taking it out of the line displaying the bot's score, and the picture disappeared on the scoreboard. Does this mean it's showing the picture for the current client entity? If so might the bots end up all having their parent player's picture next to their scores? Is there a way around this?

Maybe, when you're outputting each player's details on the scoreboard, you temporarily change the client's name/ picture to the one for the bot? And then just change it back straight after you've outputted each score?

Quote
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.

Interesting. Yeah to get it to work I think I mixed up stuff from that and the famke bot tutorial here:

http://www.telefragged.com/thefatal/old/tut.htm

Anyway thanks for your help.

7
Quake / Re: Question About Spawning a Bot in Quake 2
« on: August 08, 2009, 11:09:34 AM »
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.

8
Quake / Re: Question About Spawning a Bot in Quake 2
« on: August 07, 2009, 10:52:38 AM »
Awesome, thanks for the detailed reply. I'll analyse that in detail as soon as I get a chance.

Actually the line:

Code: [Select]
newOak->client = gi.TagMalloc(sizeof(gclient_t), TAG_GAME);
is based on the old famke bot tutorial here:

http://www.telefragged.com/thefatal/old/tut.htm

Except in that code, it's

Code: [Select]
bot->client = gi.TagMalloc(sizeof(gclient_t), TAG_GAME); //sets bot client value so it can be used
I can't remember why I included it- I think it made it work when it otherwise wouldn't have, at some point. Anyway thanks again for your advice mate.

9
Quake / Re: Question About Spawning a Bot in Quake 2
« on: August 07, 2009, 02:45:50 AM »
Thanks. I'm pretty new to this stuff though, so I have a couple of questions.

When you say "client index" do you mean "newOak->client" as in the following?

newOak->client = gi.TagMalloc(sizeof(gclient_t), TAG_GAME);

So from what you're saying that should be set to NULL? The above is from the original bot so I thought it would be the right way to do things.

Or alternately are you saying that using a for loop like this:

for (i=0 ; i < maxclients->value ; i++)

will make the bot seem like a client to the game, by affecting it's client index? If so is it ok to leave the previous line as it is?

I was thinking I could just alter the scoreboard code so that it reads from edict_t entities other than ones that are < maxclients->value. In other words, it looks for any bots with higher values. With that said I'll try what you said, because it sounds like I could learn something in the process. I'm just curious to understand how these things work.

Thanks.

10
Quake / Question About Spawning a Bot in Quake 2
« on: August 06, 2009, 10:56:59 AM »
Hi,

I've been experimenting with getting a bot to work in Quake 2, based on these tutorials:

http://www.quake2.com/dll/tutorials/bot/oak1.html
http://www.telefragged.com/thefatal/old/tut.htm

I've managed to get a bot to appear when I type in a command, but there are a few problems. When it spawns it, it doesn't appear on the scoreboard. To solve this, I tried messing around with the addbot function in the code I based on those tutorials. So instead of creating a bot by doing something like:

newOak = G_Spawn();
newOak->client = gi.TagMalloc(sizeof(gclient_t), TAG_GAME);

I tried this commenting out the first of those lines, and adding this:

for (i=0 ; i < maxclients->value ; i++) {
    cl_ent = g_edicts + 1 + i;
    if (!cl_ent->inuse) {
        G_InitEdict (cl_ent);
        newOak = cl_ent;
        break;
    }
}

I figured that would get the bot's score to display on the scoreboard, because the board only displays scores up to maxclients->value. To my surprise, it worked, and the bot's score displayed on there.

But as I said, there are problems. When the bot starts the game, it just kind of hovers in mid-air, as if it's stuck in the middle of a jumping frame. When I kill it and it respawns, it just keeps cycling through all it's animation frames endlessly- unlike before, when the bot would run over to you and start saluting. I altered the respawn function to include pain and die stuff, so I can kill it again, and it does pain appropriately, but that's all.

Anyway if anyone knows what the problem's likely to be here I'd appreciate any help you can give. I'm pretty new to this stuff, but I really enjoy it. Thanks guys.

11
Quake / Turning off Anti-Aliasing in Quake 2
« on: August 05, 2009, 02:08:21 PM »
Hi,

I seem to remember ages ago I read that there's a console command to turn off anti-aliasing in Quake 2. Is this true? If so, can anyone remember what it is?

Thanks.

12
Quake / Re: Understanding Use of gclient_t in Q2 Source Code
« on: August 05, 2009, 08:29:12 AM »
Yeah, that sorted it out. Thanks!

13
Quake / Understanding Use of gclient_t in Q2 Source Code
« on: August 05, 2009, 05:05:17 AM »
Hi,

I've been messing around with the source code for Quake 2, and I have a question about it, if anyone can help. In the file "p_client.c", inside the function "PutClientInServer", they declare a pointer like this: "gclient_t *client;".

So say I make another source code file, say "bot.c", and then include the same header files that "PutClientInServer" has. If I make a function in that, and try to declare a pointer in it like this: "gclient_t *client;", I get an error when I try to compile: "error C2275: 'gclient_t' : illegal use of this type as an expression".

Does anyone know why this happens? Ultimately, what I'm trying to do is figure out how to get a bot to have it's score displayed on the scoreboard. I'm messing around with the code to the Oakbot and the Famkebot from these sites:

http://www.quake2.com/dll/tutorials/bot/oak1.html
http://www.telefragged.com/thefatal/old/tut.htm

Thanks guys.

14
Quake / Re: Nightmare Mode Mod for Quake 2
« on: April 29, 2009, 02:18:06 PM »
R1CH, thanks, that's bloody cool. I've just been screwing around with it, and just moved the info_player_start in base1 around, so I've got it bloody working. Awesome.

The only problem is, I can't seem to get any kind of OpenGL working with R1Q2, for some reason. If I try to put it in opengl mode, I get the following error:

Failed to load ref_gl.dll: re.Init() failed

The only gl I have in my quake 2 folder is the ref_r1gl.dll, and when I select that one in the menu, it crashes. It's weird because I tried R1Q2 a while ago, and I seem to remember that working ok in opengl mode.

Anyway thanks man, it seems like I'll totally be able to get my mod going now. BTW I like the ability to increase your max frame rate. I just read about you being able to increase cl_maxfps on your site, so I tried increasing it to 100 in R1Q2. It makes it look so much better! I never realised that was why Quake 2 didn't look as smooth as Q1.

15
Quake / Nightmare Mode Mod for Quake 2
« on: April 29, 2009, 10:53:52 AM »
Hi,

For ages, I've had this idea for a mod for Quake 2. I was intending to learn how to program it myself, because it seems like it could be a really good laugh. However, based on some advice I've received, I think I'm just going to focus on learning C++ for the time being.

So anyway I just thought I'd throw the idea of the mod out there to see if anyone more experienced might be interested in programming it.

Basically, all the mod would do is change the entities in the single player maps, so that there are loads more monsters/ weapons etc. I think it would be pretty simple to program, because all you'd need would be a dll (I think), and a config file that has the details for the new monsters for each map (ie what they are, where they are, etc.).

With people's computers being so much more powerful than when Quake 2 was released, you could have masses of monsters in the maps. It'd be awesome- sorta like "The Courtyard" or "Suburbs" maps in Doom 2, which were absolute mayhem.

The thing is, if anyone's interested, I could come up with all the config files with the details of the new entities myself, because I've a reasonable amount of experience in mapping (I made a single-player episode for Half-Life, called Operation Nova, which is up at: http://www.moddb.com/mods/half-life-operation-nova). Basically I know how to look at the bsp files in Quark and find out what the appropriate origin/ angle values for the entities would be etc.

As I alluded to earlier, I don't really have time to learn how to program this myself, but it seems like it would be simple to do (for someone with the necessary programming skill/ experience). So would anyone be interested in carrying out the programming side? I'm thinking the config file could have the name of each map and then the new entities to spawn in it, something like:

map e1m1
monster_gunner
origin 120, 200, 50

etc...

So, anyone interested? I doubt there will be, but what the hell, just thought I'd ask anyway. Some of the maps in the single-player campaign are really massive- I used to love playing through them- but I just think it'd be better if there were more enemies to slaughter. It'd really breathe new life into the game.

Anyway, cheers, thanks for reading this far, if anyone has had the patience to.

Pages: [1] 2