Hello, I need to get data about bots in the game from the game into something readable be another program. Does anyone know any easy way to do this? I thought it’d be easy even for a novice C programmer but I’ve just discovered that you can’t use standard libraries and then compile the game. If you think that there’s no clever way of doing this then please say so, It’d be useful to know that this is a pointless endeavour, or one that requires skills that I lack.
The game appears to be compiled against the standard C libraries. For example, see https://github.com/ioquake/ioq3/blob/master/code/client/cl_main.c#L544
The question of where to do the writing from is more complicated, that depends on exacly what you want to store.
my understanding is that you can’t use any of the standard c libraries, idk what’s going on in that file: http://wiki.ioquake3.org/Getting_the_most_from_Quake3_C . I’ve also tried compiling the game with nothing changed in the code apart from adding ‘#include <stdio.h>’ in ‘ai_main.c’, and that leads to the compiler returning an error
Sorry, it’s been ages since I messed with this stuff
So there are two different kinds of C code in the source tree: there’s the engine and tools code which is compiled into normal native binaries and there’s the “game/mission pack” code that is compiled into… something. I’m not entirely clear on this because it looks like there are object modules (.o files) from these that seem to be just plain native object modules but also .asm files that are most definitely not normal x86 assembly. In any case, the engine code gets to use the standard library, it looks like the game code does not.
Since it sounds like you want information from the bots, if there are no functions to do arbitrary file IO available to the game code, I expect you’d have to provide a way to do so that is accessible from the VM (it looks like this can be done through the “syscall” interface). However, that wouldn’t be portable: you couldn’t just run it on anyone’s client/server, it would have to be run on your modified client/server.
But I think the easiest thing to do may be to use Com_Printf() or something like that to write a specially formatted message to the console and logfile. Then parse those messages out from the program where you’re trying to capture the data. It’s not pretty, but it gets the job done.
what exactly is the logfile called? I’m new to this, when I searched through my ioq3 directory after playing a ctf game couldn’t find any informative readable files that had ‘log’ in the name. Is there any reason this wouldn’t work if standalone assets (ie openarena assets) are used?
It looks like logfiles get stored in your $HOME/.q3a/baseg3 directory, at least for the normal game. For mods they might be under mod subdirectories in $HOME/.q3a.
There’s a cvar that controls the logfile name, “g_log”. Setting this created a new logfile for me.
that works but the log goes straight to the mingw console? any way around this? -well to be more specific, using /logfile returns ‘log file opened’ and it’s showing ‘xxx died to xxx’ in the mingw terminal, i assume that’s what the logs are mean to do lol. Even if you can’t help, thanks for trying!
i found where the logfiles are, it’s not just sticking everything in the mingw terminal as far as i can tell… it was in ‘C:\Users\Dominic\AppData\Roaming\Quake3\baseoa’. Thanks for taking the time to help
Cool, I wasn’t sure where the .q3a directory mapped to under Windows. But that makes sense. It sounds like $HOME/.q3a -> C:\Users<your-id>\AppData\Roaming\Quake3 on Windows.
Anyway, glad to hear it worked out!
The wiki has some tips for getting to that directory quickly, and similar locations on every platform: http://wiki.ioquake3.org/Players_Guide#Where_are_my_files.3F_I.27m_used_to_them_being_in_the_Quake_3_directory.21
should com_printf go to the console? are there any rules about where/how it can be used? I try printing from ai_main.c and the logfile certainly doesn’t have anything that I wanted it to print in
G_LogPrintf() to print to the games.log file.
is there a reason that these might not work with a mod enabled? Or any mistakes you think I might be making? I’m trying to do this with openarena files and I’ve seen no sign of any of the various print functions that i’m putting into the code working
which vm/qagame.qvm console command to check if ioq3 is using your mod code or mod from in a pk3.
i literally realised that jsut as you posted lol
well, i realised that it might be using the wrong code… thanks
after ages of doing it wrong and using gamefiles I hadn’t edited, I’ve finally got it working on a linux vm- thanks