Inside3D!
     

Global variables - how?

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
Nash



Joined: 19 Oct 2007
Posts: 95
Location: Kuala Lumpur, Malaysia

PostPosted: Sun Nov 11, 2007 11:10 pm    Post subject: Global variables - how? Reply with quote

How do I create floats or custom fields that do not get reset when the map changes?

I want to do something like, a secret triggered from the previous map can only be seen on the next map. Stuff like that.

No, I don't want to use the dummy cvars because I don't want players to freely set the cvar.

I think it's possible because the player items are saved for the next map but I don't understand how it works.

Thanks in advance.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
daemon



Joined: 07 Nov 2007
Posts: 62

PostPosted: Sun Nov 11, 2007 11:50 pm    Post subject: Reply with quote

The way the player items and stats are saved is by setting the player's parms to those values, and each player's parms are carried over through map changes, then loaded back into the variables once the map is loaded.

So, if you wanted to use parms to carry over global values, you could probably use spawnclient() to create a fake client and use it's parm values to hold the global values you want to save.

OR

You could use FRIK_FILE to save those values to a file before the map change, and then load them back into the global variables on the next map start.

I would probably use the FRIK_FILE method if I didn't want to use up a player slot, and/or I had a LOT of global variables I wanted to carry though level changes.

You could ALSO use the serverflags variable to store values like parms, but that is already used by many things in Quake, and since there is only one of them, you are limited as to how much and what kind of information you can store in it. If all you want to save is true/false flags, then serverflags might be what you want.
_________________
-daemon [ daemonforge.org ]
Back to top
View user's profile Send private message Visit poster's website
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Mon Nov 12, 2007 4:44 am    Post subject: Reply with quote

What is serverflags all used by? I think the first four 'bits' were used for runes, but is the rest of it ever used? If not, you have 20-ish bits you can use for global boolean flags...
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
daemon



Joined: 07 Nov 2007
Posts: 62

PostPosted: Mon Nov 12, 2007 10:19 am    Post subject: Reply with quote

It looks like just the first 4 were used, but impulse11 also does this by default:

serverflags = serverflags * 2 + 1;
_________________
-daemon [ daemonforge.org ]
Back to top
View user's profile Send private message Visit poster's website
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Mon Nov 12, 2007 12:59 pm    Post subject: Reply with quote

Hehe yeah, you might want to change that one so it doesn't touch beyond the first four bits...
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
Nash



Joined: 19 Oct 2007
Posts: 95
Location: Kuala Lumpur, Malaysia

PostPosted: Mon Nov 12, 2007 2:20 pm    Post subject: Reply with quote

FRIK_FILE seems to be the most elegant solution. Thanks daemon!
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Mon Nov 12, 2007 7:46 pm    Post subject: Reply with quote

I recommend that you still use one of the bits in serverflags to signify the presence of data from the previous map. Failure to do so might otherwise result in awkwardness when starting a new game. Just one flag.

yeah, only four bits of serverflags are normally used. and impulse 11 is a cheat. Razz
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group