]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
defaultplayermodel: allow multiple and randomize
authorRudolf Polzer <divverent@xonotic.org>
Sat, 26 Nov 2011 16:38:24 +0000 (17:38 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 26 Nov 2011 16:38:24 +0000 (17:38 +0100)
defaultXonotic.cfg
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh

index 80307c2850ae119ddfddad2a42ef0379919e5abe..27fcf03bfa9cc07831a9f1cb2bb8c74a1f4674fd 100644 (file)
@@ -399,8 +399,8 @@ seta sv_precacheitems 0
 set sv_spectator_speed_multiplier 1.5
 seta sv_spectate 1 "if set to 1, new clients are allowed to spectate or observe the game, if set to 0 joining clients spawn as players immediately (no spectating)"
 seta sv_defaultcharacter 0 "master switch, if set to 1 the further configuration for replacing all player models, skins and colors is taken from the sv_defaultplayermodel, sv_defaultplayerskin and sv_defaultplayercolors variables"
-seta sv_defaultplayermodel "models/player/erebus.iqm" "default model selection, only works if sv_defaultcharacter is set to 1"
-seta sv_defaultplayerskin 0 "each model has 1 or more skins (combination of model and skin = character), set which skin of the model you wish the default character to have, only works if sv_defaultcharacter is set to 1"
+seta sv_defaultplayermodel "models/player/erebus.iqm" "default model selection, only works if sv_defaultcharacter is set to 1; you may append a :<skinnumber> suffix to model names; you can specify multiple, separated by space, and a random one will be chosen"
+seta sv_defaultplayerskin 0 "each model has 1 or more skins (combination of model and skin = character), set which skin of the model you wish the default character to have, only works if sv_defaultcharacter is set to 1; can be overriden by :<skinnumber> suffix in sv_defaultplayermodel"
 seta sv_defaultplayermodel_red ""      "\"\" means see sv_defaultplayermodel"
 seta sv_defaultplayerskin_red 0
 seta sv_defaultplayermodel_blue "" "\"\" means see sv_defaultplayermodel"
index b56add1c76ab8f5f2709fc5f67185d9fb4f05699..47c0c4f0f42db7264501256977f1c465c6b22d67 100644 (file)
@@ -757,15 +757,17 @@ void PutObserverInServer (void)
                self.frags = FRAGS_SPECTATOR;
 }
 
+.float model_randomizer;
 void FixPlayermodel()
 {
        string defaultmodel;
-       float defaultskin, chmdl, oldskin;
+       float defaultskin, chmdl, oldskin, n, i;
        vector m1, m2;
 
        defaultmodel = "";
 
-       if(autocvar_sv_defaultcharacter == 1) {
+       if(autocvar_sv_defaultcharacter == 1)
+       {
                defaultskin = 0;
 
                if(teamplay)
@@ -784,6 +786,17 @@ void FixPlayermodel()
                        defaultmodel = autocvar_sv_defaultplayermodel;
                        defaultskin = autocvar_sv_defaultplayerskin;
                }
+
+               n = tokenize_console(defaultmodel);
+               if(n > 0)
+                       defaultmodel = argv(floor(n * self.model_randomizer));
+
+               i = strstrofs(defaultmodel, ":", 0);
+               if(i >= 0)
+               {
+                       defaultskin = stof(substring(defaultmodel, i+1, -1));
+                       defaultmodel = substring(defaultmodel, 0, i);
+               }
        }
 
        if(self.modelindex == 0 && self.deadflag == DEAD_NO)
@@ -1796,6 +1809,8 @@ void ClientConnect (void)
 
        if(!autocvar_g_campaign)
                Send_CSQC_Centerprint_Generic(self, CPID_MOTD, getwelcomemessage(), autocvar_welcome_message_time, 0);
+
+       self.model_randomizer = random();
 }
 
 /*
index 2a09d261cc8735485b3e9fff27b4eb3c02b211ab..21d6db4401ed5f4730390de6002fde6080a1dfd3 100644 (file)
@@ -669,4 +669,3 @@ float serverflags;
 .float misc_bulletcounter;     // replaces uzi & hlac bullet counter.
 
 void PlayerUseKey();
-