multiplayer variable meanings

Discuss programming in the QuakeC language.
Post Reply
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

multiplayer variable meanings

Post by Seven »

Hello,

I am sorry for this silly question, but I never played/used multiplayer syntax before.

Working on something new at the moment I also have to take multiplayer in account.
There are these 2 multiplayer variables everywhere in the QuakeC source:
- coop
- deathmatch

Sometimes it checks for "deathmatch == 2", sometimes for "deathmatch == 1"
What is the meaning of "1" and "2" ?
And are there others besides "0" ? (maybe "3" ?)

Has "coop" also different values ?
I never see a check for "coop ==1" or "coop ==2".
Or is only "0" and "1" possible for "coop" ?


Then my next question (once I understood the syntax above):
If I want to check if the current running game is ANY multiplayer game variation.

Can I do it same this ?

Code: Select all

if (deathmatch == 1 || deathmatch == 2 || coop)
   *do this cause game is multiplayer*
else   // then it must be single player 
   *do that cause game is single player*
Would this be the same ?

Code: Select all

if (coop || deathmatch)
   *do this cause game is multiplayer*
else   // then it must be single player 
   *do that cause game is single player*
I am only speaking about regular QC 1.06 here (no custom mod like quakeworld or team fortress, ...)

The reason why I ask is, because of respawn function.
I *think* only multiplayer games (deathmatch "1" or "2" or coop) in original QC 1.06 have powerup respawn, right ?

Thank you for your answers and helping me to understand multiplayer and how to check for it.
Seven
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: multiplayer variable meanings

Post by Baker »

If you are looking to detect a multiplayer game, I would recommend reading the maxplayers cvar (except I think there is a better QuakeC way because what you really want is svs.maxclients exposed to QuakeC).

In a true single player game, maxplayers is 1.

However, I suspect reading the cvar is not the right way to do it in QuakeC .... I'll see if I can locate the correct method if someone doesn't beat me to it.

deathmatch and coop cvars have nothing to do with multiplayer, they have to do with game rules as QuakeC interprets them. For instance, start up Quake to the start map and type in the console "deathmatch 0; coop 0; map start". You'll find yourself sitting around on the start map. Type in the console "deathmatch 1; coop 1; map start" .... again you are sitting around on the start map. But you aren't in multiplayer.

Add:

Continued ... well, "maxplayers" is actually a command not a cvar so you cannot check the value ....
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: multiplayer variable meanings

Post by Baker »

Seven, you might try to reframe the question. Here is why.

I think you are looking for the wrong thing. Game rules shouldn't be dependent on the potential ability for more than 1 player to be participating.

Example: I am the only player on a server. Is it a multiplayer game?

Cvars like deathmatch or coop should be controlling the behavior of the QuakeC.

This would be the correct answer for what you are looking for:

Code: Select all

if (coop || deathmatch)
   *because coop or deathmatch game rules will be in effect, which you still want to be able to test by yourself even with 1 client*
else    
   *because neither coop or deathmatch game rules are in effect, which are the appropriate game rules for single player*
You might want to change deathmatch to 1 and load up DM6, you respawn when you die instead of the map restarting and ammo will respawn. Even though you are the only player.

Note: the deathmatch and coop servers do not really have any sort of limitation on them. You can type coop 726783 in the console. QuakeC decides what "coop" does.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: multiplayer variable meanings

Post by Seven »

Hello Baker,

First of all, Thank you for your reply.
My reason for asking had another background.
It is important to know in which gametype I am at the moment, to be able to use the correct effect type for powerups and stuff.

To use your example:
If I start for example e1m1 map and type deathmatch "1" (I still dont know the difference to "2" by the way) ;)
The powerups / weapons will respawn if I take them, right ?
And that is enough for me to know at the moment.
Because I will then use the "respawn version" effect and all related things on them.
Even if I am the only player on 1 server, the fact that "deathmatch is not "0"" will make the difference of
powerup and weapon and stuff behaviour (respawn).

I of course know, that there is much more engine and QC side that matters when you are in a multipleayer game,
but this is for my small mod not important (cause I dont want to change these things).
I am struggeling with effects (as usual, as you know me) and unfortunately powerups behave a little different
when in multiplayer game compared to single player.

As you know, my QC steps are small and I need to do them one by one. :)
Coding time related particle effects is my target at the moment. Like a shader (ex. animMap) does for textures, but for particle effects.
I make good progress, but the fact that they appear again (after 20 seconds in multiplayer) gives me some trouble.
So I need 2 seperate ways of doing it (cause powerups are initialy "drop" in the map at the beginning of map start (with Startitem () ).
And the deathmatch respawn does not put them the same way into the map again as the initial process.
And exactly this is causing my small problem.
But this can be solved with this check I plan to do (that is my guess at least).

I didnt want to bore people by writing so much in this thread. Sorry.
Just to explain a little better what my intention was.

So I guess this will do the trick, right ?

Code: Select all

if (coop || deathmatch)
   *do this cause game is multiplayer*
else   // then it must be single player
   *do that cause game is single player*
And it would be very nice if someone could tell me the difference of deathmatch "1" and "2" (it interests me)
and if the code above will filter ALL multiplayer (=respawn powerups/armors/ weapons) game types ? (not speaking about QW or TF)

Sorry for my awkward way of expressing myself (even in german I have this problem ;) )
I hope I didnt misunderstood your posts Baker, but I guess you focused / tried to help me on another direction ?

Thank you very much.
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: multiplayer variable meanings

Post by Baker »

http://www.quakewiki.net/archives/conso ... deathmatch

Yes, your if statement should achieve your goal.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: multiplayer variable meanings

Post by Seven »

Thank you Baker !

That link you provided has very useful information and detailed description of Quake cvars/commands.
...and there is even a deathmatch "3" (it is the most common setting it seems) :)
Now I can continue...
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: multiplayer variable meanings

Post by frag.machine »

From what I remember of the original code, when you select "Single Player" in Quake menu the following sequence of console commands are issued:

Code: Select all

disconnect
maxplayers 1
map start
So, the engine assumes "single player == maxplayers 1".
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
necros
Posts: 77
Joined: Thu Dec 16, 2004 10:32 pm

Re: multiplayer variable meanings

Post by necros »

iirc, deathmatch 2 is commented in a spot as 'old silly rules'.
look in items.qc in the places which handle item respawning.
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: multiplayer variable meanings

Post by Seven »

Hello frag.machine & necros,

Thank you for your replies too.
I was able to finish the "time-dependent particle effects" in the meantime.


But one thing I would like to mention; because the information in Bakers link seems not to match Quake multiplayer behaviour.
(at least in DarkPlaces).

Quakewiki says (taken from Bakers link):
0 - Deathmatch is disabled.
1 - Deathmatch is enabled. Picked up weapons will disappear, ammo and powerups will respawn.
2 - Deathmatch is enabled. Picked up weapons will not disappear, ammo and powerups will not respawn.
3 - Deathmatch is enabled. Picked up weapons will not disappear, ammo and powerups will respawn.
(In DarkPlaces) the behaviour is a little different (below are my notes):

Code: Select all

0 - Deathmatch is disabled.
1 - Deathmatch is enabled. Picked up weapons will disappear, ammo and powerups and armor will respawn.
2 - Deathmatch is enabled. Picked up weapons will not disappear, ammo and armor will not respawn, powerups will respawn.
3 - Deathmatch is enabled. Picked up weapons will disappear, ammo and armor will not respawn, powerups will respawn.
Best wishes and a great start into 2012 !
Seven
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: multiplayer variable meanings

Post by Baker »

deathmatch 3 missing in NQ was either an unfixed oversight or well ... who knows. It exists in Quakeworld and is easily coded into any NQ mod.

Orion's QC instructions on implementing "deathmatch 3". If interested ...

http://forums.inside3d.com/viewtopic.php?p=9739
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Post Reply