carrying variables over from one map to another...

Discuss programming in the QuakeC language.
Post Reply
necros
Posts: 77
Joined: Thu Dec 16, 2004 10:32 pm

carrying variables over from one map to another...

Post by necros »

is it possible to, for example, carry the "total monsters" and the "monsters killed" variables from one map so that you can add them to the variables in another map?
i know quake can do that with ammo, but how do you make a 'permanent' variable like that?
Urre
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon
Contact:

Post by Urre »

Parms are pretty darn permanent...

Then there's always FRIK_FILE, assuming you're using an engine that supports it.
I was once a Quake modder
necros
Posts: 77
Joined: Thu Dec 16, 2004 10:32 pm

Post by necros »

if possible, i'd like to keep everything compatible with original quake... :\
Wazat
Posts: 771
Joined: Fri Oct 15, 2004 9:50 pm
Location: Middle 'o the desert, USA

Post by Wazat »

Parms, then. You'll find them near the top of client.qc.
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
Wazat
Posts: 771
Joined: Fri Oct 15, 2004 9:50 pm
Location: Middle 'o the desert, USA

Post by Wazat »

...btw, there's also temp1, gamecfg, nomonsters, savedgamecfg, saved1-5, etc. Those cvars can be fairly useful, and they stay the same across maps.
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
necros
Posts: 77
Joined: Thu Dec 16, 2004 10:32 pm

Post by necros »

thanks! i didn't know there were so many of those.

about parm, there are up to parm16 declared in defs.qc... when (if at all) are parm10-16 used? i only see 1 to 9 used for SP ammo/items.
Wazat
Posts: 771
Joined: Fri Oct 15, 2004 9:50 pm
Location: Middle 'o the desert, USA

Post by Wazat »

You can use any and all of the parms as you please. There's no pre-defined order you have to store things in, and none of the stuff is really required. If your mod gives players 100 health each time they start a level, then you don't need to store health in a parm. If you don't need to store ammo, you can remove those. You might store all that information using FRIK_FILE in your mod, and not need any more than 1 parm (to store client ID to match players to their save files).

Likewise you can use the other, unused parms for whatever purpose you deem necessary.
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
necros
Posts: 77
Joined: Thu Dec 16, 2004 10:32 pm

Post by necros »

ah, so they are unused, then? thanks! this is great, i didn't know quake had hidden gems like this. ;)
necros
Posts: 77
Joined: Thu Dec 16, 2004 10:32 pm

sorry to ressurect the thread,

Post by necros »

but i have another question on this topic, specifically, how do you use the variables saved1-4 in qc? it's easy to do it via the console in the game, but how can one access these vars in qc?

i've tried delcaring a float 'saved1' but this is just treated as a normal float and not the actual saved1 i want.

any help?
Supa
Posts: 164
Joined: Tue Oct 26, 2004 8:10 am

Re: sorry to ressurect the thread,

Post by Supa »

You'd use savedX like any other cvar in Quake: use stuffcmd/localcmd (Preferrably stuffcmd for SP) to set it and use 'cvar' to read it.:

stuffcmd(player, "cl_foo 3\n");
(later)
self.bar = cvar("cl_foo");
aut viam inveniam aut faciam
FrikaC
Site Admin
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Post by FrikaC »

If you need a bit more than 10-16, I should note that parm9's use in Quake is kinda pointless. It stores the "armortype" variable, a variable with only 4 possible values all of which are already flagged in .items.

So all you need to do to free up parm9 is add this to the bottom of DecodeLevelParms:

if (self.items & IT_ARMOR1)
self.armortype = 0.3;
else if (self.items & IT_ARMOR2)
self.armortype = 0.6;
else if (self.items & IT_ARMOR3)
self.armortype = 0.8;
else
self.armortype = 0;
FrikaC
Site Admin
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Post by FrikaC »

Oh, and you really should use cvar_set for setting cvars, not stuffcmd or localcmd.
Wazat
Posts: 771
Joined: Fri Oct 15, 2004 9:50 pm
Location: Middle 'o the desert, USA

Post by Wazat »

Yea, as FrikaC said, use cvar to read and cvar_set to modify.

There's also savedgamecfg, which I think is just like saved1 etc.

There's also gamecfg, temp1, and nomonsters. These aren't saved in the cfg files, which can make them more or less useful. You can change them without worrying about their settings carrying over to the next time the user starts quake. Set them just before the map changes and load them just after the level starts (in worldspawn()). If you store their values as floats during game and only set & load them for map changes, they should be saved in save games, right?

I'm sure there are others. And in DP you can make your own cvars...
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
necros
Posts: 77
Joined: Thu Dec 16, 2004 10:32 pm

thanks!

Post by necros »

wow, thanks for all the help, guys! there's still so much for me to learn about qc. :P
Post Reply