Quake3World.com Forums
     Quake III Arena/Quake Live Discussion
        Load config file depending on map that is played


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC





Previous topic | Next topic 
Topic Starter Topic: Load config file depending on map that is played

Gibblet
Gibblet

Joined: 26 Mar 2012
Posts: 11
PostPosted: 03-26-2012 10:30 AM           Profile Send private message  E-mail  Edit post Reply with quote


Hello.

I am a grad student studying visual attention and want to run an experiment using Q3. It's something like a fun project on the side. ;) I am still figuring out the details but already have some questions that I hoped you could help me with. Here's what I want to do:

1) Load map X and let the user play for 5 minutes to get familiar with the game.
2) Load next map and change time limit to 10 minutes. Possibly load another configuration file to change graphics.
3) Load next map and possibly load yet another configuration file to change graphics.

This should be automated so that I can start the game for one subject and don't have to enter the room again until the end of the experiment. Also, the user should not be required to do anything but play the game. Therefore, my question is: How/where do I configure the sequence of maps and the game options (time limits etc.)? And also: Is it possible to load a new config file every time the map changes?

Thanks a lot for any help!




Top
                 

Cool #9
Cool #9

Joined: 01 Dec 2000
Posts: 38345
PostPosted: 03-26-2012 11:44 PM           Profile   Send private message  E-mail  Edit post Reply with quote


It's not too hard. Simply create a text file in the baseq3 folder inside your Quake III Arena installation folder. Give it a .cfg filename extension (instead of .txt). Then you can start Quake 3, open the console with the tilde (~) key and type:

\exec filename.cfg

where filename should of course be replaced by the name of the cfg file you created. You can also start Quake 3 and automatically have the cfg file executed by creating a text file with a .bat filename extension, put it in your Quake III Arena installation folder and put the following in it:

quake3.exe +exec filename.cfg


So now the next question. What to put in that .cfg file?

you can define variables in Quake 3 scripts and assign lists of commands to those variables. These commands can then be executed from within the script. This is done as follows:

Code:
set v1 "map q3dm1; set nextmap vstr v2"
set v2 "map q3dm2; set nextmap vstr v1"
vstr v1


The "set" command assigns a value to a variable. In this case we define two variables: v1 and v2. The commands we assign to a variable can be executed using the "vstr" command. So "vstr v1" means "execute the commands stored in the v1 variable".

First a "map" command is assigned to each of these variables which will inform Quake 3 to load the specified map. Each variable also gets a "set" command assigned. This set command assigns a value to the "nextmap" variable. The nextmap variable is a special system variable whose commands are executed whenever a game in a map ends.

So basically we say that when v1 is executed, we want v2 to be executed when the game ends and vice versa. Finally we execute the commands in v1 to get the thing going.

So this is basic script used by servers all over the world to get a server to rotate through a set of maps. This can be expanded with additional things. Example:

Code:
set v1 "timelimit 5; map q3dm1; set nextmap vstr v2"
set v2 "timelimit 10; map q3dm2; set nextmap vstr v1"
vstr v1


We now set a timelimit. This means that the first game (in q3dm1) will last for 5 minutes and the second game (in q3dm2) will last 10 minutes.
Finally, you said you wanted to load different graphics settings for each map. This is possible, but ONLY if the player is playing a local game. If he is connected to a separate (dedicated) server (even if it's running on his own machine), it won't work.

You can also add graphics related settings to your script, like so:

Code:
set v1 "r_picmip 3; vid_restart; timelimit 5; map q3dm1; set nextmap vstr v2"
set v2 "r_picmip 0; vid_restart; timelimit 10; map q3dm2; set nextmap vstr v1"
vstr v1


This script will set the picmip level to 3 (lower quality textures) for the first map and sets it to 0 (highest quality) for the second map. I think the vid_restart command is required to reinitialize the graphics renderer to take the new setting into account, but it could be that this is already automatically done when the new map is loaded. Just try it with and without vid_restart and see what happens.

I'm not going to point out and explain all graphics settings that exist. Google for those (or simply type \r_ in the console and hit tab, you'll get a list of all renderer related settings. That covers most of it)

If you really want to change a lot of graphics settings and your command variables get cluttered, you could also put those commands in a different cfg file and execute that, like so:

Code:
set v1 "exec gfx1.cfg; timelimit 5; map q3dm1; set nextmap vstr v2"
set v2 "exec gfx2.cfg; timelimit 10; map q3dm2; set nextmap vstr v1"
vstr v1



example of gfx1.cfg:
Code:
r_picmip 0
r_lightmap 0
vid_restart


Good luck with it!



_________________
Signature


Top
                 

Gibblet
Gibblet

Joined: 26 Mar 2012
Posts: 11
PostPosted: 03-27-2012 08:16 AM           Profile Send private message  E-mail  Edit post Reply with quote


Hello Eraser. Thanks a lot! That was exactly what I was looking for and should make my life a lot easier. Awesome!

I hope to find time to play around with this in the next couple of days and then get the experiment running as soon as possible. If we get interesting results, I'll make sure to post about it here. :)




Top
                 

Messatsu Ko Jy-ouu
Messatsu Ko Jy-ouu

Joined: 24 Nov 2000
Posts: 41256
PostPosted: 03-27-2012 11:08 AM           Profile   Send private message  E-mail  Edit post Reply with quote


doesnt a mapchange include a vid_restart though?
[edit] oh i see you covered that :)




Top
                 

Gibblet
Gibblet

Joined: 26 Mar 2012
Posts: 11
PostPosted: 04-02-2012 05:32 PM           Profile Send private message  E-mail  Edit post Reply with quote


Hey guys,

Everything you posted above worked perfectly, thanks a lot, Eraser. I have a follow up question regarding this.

I ended up "installing" CPMA because it gives me a couple of options that make my life a lot easier. What I do now is open the game, load CPMA, start my own game and then \callvote mode IFFA to play in instagib. It works, but I want to automate this.

Is there any way I can put this into a .cfg file that I can then load with a batch file as described above?

More specifically, the parameters I want to set are 1) the time limit, 2) the number of bots, 3) the map, and, as I said, 4) that it uses CPMA's instagib mode.

Thanks a lot for your help!




Top
                 

Cool #9
Cool #9

Joined: 01 Dec 2000
Posts: 38345
PostPosted: 04-02-2012 10:38 PM           Profile   Send private message  E-mail  Edit post Reply with quote


You can control the bots in two ways. First there's the bot_minplayers cvar. This controls the minimum number of players that must be present on your server. So if you set bot_minplayers to 8 and three real life people have connected to your server, then the server will add 5 random bots to fill it up to 8 players again. If another player connects, it removes one bot. If a player disconnects, it adds a random bot.

The other option is to add the bots manually. Then these bots will stay on the server until they are explicitly removed again. You can do this with the addbot command. The syntax is:

\addbot [name] [skill] [team] [delay] [altname]

[name] should be replaced with the name of the bot (eg: "sarge" or "ranger").
[skill] is a value ranging from 1 to 5. 1 being the easiest (i can win) and 5 being the hardest (nightmare).
[team] is either "red", "blue" or "free". If you're not playing team based games, simply specify "free".
[delay] is a delay in milliseconds before the bot connects. So if you specify a value of 10000, then the bot will connect 10 seconds after you've issued the command.
[altname] is an alternative name for the bot that I think other bots use to refer to this bot in their chat lines.

Easiest is to just omit delay and altname and also omit team if you're playing Free For All. So you could just use

\addbot Sarge 4

to add a Sarge bot add the Hardcore skill level.

As for setting CPMA to instagib, I'm sure there's some cvar to set for that but I'm not familiar enough with the CPMA mod to know how it's done. Someone else probably will know and I'm sure it's described somewhere in the documentation that comes with CPMA as well.

Naturally, the commands I've described can be included in the vstr variables I described before.



_________________
Signature


Top
                 

visual prowess
visual prowess

Joined: 30 Jul 2004
Posts: 1114
PostPosted: 04-10-2012 05:58 PM           Profile Send private message  E-mail  Edit post Reply with quote


altname renames the bot on the scoreboard to what you want, not just the chat lines



_________________
CAPSLOCK IS ON


Top
                 

Gibblet
Gibblet

Joined: 26 Mar 2012
Posts: 11
PostPosted: 04-12-2012 03:03 PM           Profile Send private message  E-mail  Edit post Reply with quote


Hey, it's me again.

Took me a while to organize a computer that runs Q3 so I can mess with it in my office.

As I said, I am using CPMA now. Here's what I did:

In \cpma\cfg-maps\ I created q3dm1.cfg and q3dm2.cfg which contain nothing but
Code:
mode highlowexp

which in turn is defined in \cpma\modes\highlowexp.cfg and contains
Code:
type 0
instagib 1
timelimit 2
limit 0
fallingdamage 0


My map_rotation.cfg is in \baseq3\ and contains
Code:
set v1 "map q3dm1; addbot Sarge 1; set nextmap vstr v2"
set v2 "map q3dm2; set nextmap vstr v1"
vstr v1


I loads q3dm1 with IFFA mode and one bot is added. That's perfect. However, at the end of the game, it doesn't load q3dm2. It just starts another game on q3dm1. Any idea why? (The same is true if I put map_rotation.cfg in the \cpma\ sub-folder.

I had the map-switch working before (without CPMA)... I am not sure what changed or why it doesn't work anymore. Does someone have an idea?

Thanks a lot for your help!


P.S.: I also have an autoexec.cfg with some graphic settings in \baseq3\ but I don't think that matters, does it?




Top
                 

Cool #9
Cool #9

Joined: 01 Dec 2000
Posts: 38345
PostPosted: 04-18-2012 10:35 PM           Profile   Send private message  E-mail  Edit post Reply with quote


The script looks alright. Have you tried using the script without CPMA? Does it run correctly then? If so, have a look at the CPMA documentation on how to construct a working map rotation, or Google for it. I'm afraid I know nothing about the CPMA mod so unfortunately I can't help you there.



_________________
Signature


Top
                 

Gibblet
Gibblet

Joined: 26 Mar 2012
Posts: 11
PostPosted: 04-19-2012 06:58 AM           Profile Send private message  E-mail  Edit post Reply with quote


Hi,

thanks for your reply.

Here is what I did now. I wrote my own server.cfg and put it in the /cpma/cfg/ folder. The important bits in the config (from what I can tell) are:

Code:
seta mode_start highlowexp
seta mode highlowexp

seta map_delay 0
seta map_restrict 0
seta map_rotate 1

map q3dm1
addbot Sarge 1
addbot Ranger 1


In addition, I still have the q3dm1.cfg and q3dm2.cfg in /cpma/cfg-maps/. These files contain only the line "mode highlowexp". On top of that, I added a map list file for the game mode. This was missing before. The file is /cpma/cfg-maps/highlowexpmaps.txt and contains:

Code:
// mapname [minplayers] [maxplayers] [fraglimit] [timelimit]
q3dm1 0 10 0 1
q3dm2 0 10 0 1


When I load highlowexp_server.cfg, it fires up q3dm1 with my highlowexp game mode and the game finishes after the first map. It then tries to load the next map but takes me to the menu instead. I then took a look at the games.log file and am slightly confused. This is the log:

Quote:
0.0 ------------------------------------------------------------
0.0 InitGame: \sv_fps\30\sv_allowDownload\0\server_gameplay\VQ3\g_maxGameClients\0\sv_maxclients\8\sv_hostname\My Server\sv_punkbuster\0\sv_maxRate\50000\sv_minPing\0\sv_maxPing\0\sv_floodProtect\0\timelimit\1\version\Q3 1.32 win-x86 Oct 7 2002\dmflags\0\fraglimit\20\g_gametype\0\protocol\68\mapname\q3dm1\sv_privateClients\0\game\CPMA\gamename\cpma\gamedate\Jul 27 2010\gameversion\1.48\sv_arenas\1\GTV_CN\1\g_needpass\0
0.0 Game_Start: ??? in arena 0
0.0 Game_Start: FFA in arena 0
0.0 Too many classes defined: max is 8
0.0 Game_Start: FFA in arena 0
0.3 ClientConnect: 0
[...]
102.5 PlayerScreenshot: 0 FFA-Sarge-q3dm1-2012_04_19-09_52_06
102.5 PlayerScreenshot: 1 FFA-Ranger-q3dm1-2012_04_19-09_52_06
102.5 PlayerScreenshot: 2 FFA-[SU]4science!-q3dm1-2012_04_19-09_52_06
107.0 Game_Start: FFA in arena 0
107.0 ShutdownGame:
107.0 ------------------------------------------------------------
107.0 ------------------------------------------------------------
107.0 InitGame: \sv_fps\30\sv_allowDownload\0\server_gameplay\VQ3\g_maxGameClients\0\sv_maxclients\8\sv_hostname\My Server\sv_punkbuster\0\sv_maxRate\50000\sv_minPing\0\sv_maxPing\0\sv_floodProtect\0\timelimit\1\version\Q3 1.32 win-x86 Oct 7 2002\dmflags\0\fraglimit\20\g_gametype\0\protocol\68\mapname\cpm15\sv_privateClients\0\game\CPMA\gamename\cpma\gamedate\Jul 27 2010\gameversion\1.48\sv_arenas\1\Score_Time\Warmup\Score_Red\0\Score_Blue\0\Players_Active\1 2 3 \GTV_CN\1\g_needpass\0\mode_current\HIGHLOWEXP
107.0 Game_Start: ??? in arena 0
107.0 ShutdownGame:
107.0 ------------------------------------------------------------


The reason I am confused is that I don't understand where it loads the game settings from. The host name is "My Experiment" for the first and the second game. That's the name I specified in the /cpma/cfg/highlowexp_server.cfg file. However, the second time, it seems to try to load the map cpm15. But I never put that anywhere. Where does that come from?

So, I thought the reason it didn't load the next map (or: couldn't) was because no map config was available for it. Therefore, I added /cpma/cfg-maps/cpm15.cfg with the same "mode highlowexp" line. That didn't work either, though: I still get thrown to the menu.

Does anyone have an idea what's going on? I feel like I am missing something obvious...

Thanks a lot for your time!




Top
                 

Gibblet
Gibblet

Joined: 26 Mar 2012
Posts: 11
PostPosted: 04-19-2012 02:16 PM           Profile Send private message  E-mail  Edit post Reply with quote


Hi, again

we had another lab meeting and talked about this study again. We decided to slightly change the procedure which will make stuff a little easier for me.

I got pretty much everything working now. There's only one thing I want to do. I want Q3/CPMA to quit automatically after the first map is played. That is, instead of loading a new map, it should quit. Any ideas?




Top
                 

Cool #9
Cool #9

Joined: 01 Dec 2000
Posts: 38345
PostPosted: 04-19-2012 10:03 PM           Profile   Send private message  E-mail  Edit post Reply with quote


Try sticking the disconnect or quit commands in there somewhere. Note that this only works for the server, so any clients will probably return to the main menu with an error about losing the connection to the server.



_________________
Signature


Top
                 
Quake3World.com | Forum Index | Quake III Arena/Quake Live Discussion


Post new topic Reply to topic


cron
Quake3World.com
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group