From: Rudolf Polzer Date: Sat, 26 Nov 2011 16:38:24 +0000 (+0100) Subject: defaultplayermodel: allow multiple and randomize X-Git-Tag: xonotic-v0.6.0~35^2~33^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f0180ccabbe9db75166f7bea35140dd0a2cec5d7;p=xonotic%2Fxonotic-data.pk3dir.git defaultplayermodel: allow multiple and randomize --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 80307c285..27fcf03bf 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -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 : 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 : 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" diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index b56add1c7..47c0c4f0f 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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(); } /* diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 2a09d261c..21d6db440 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -669,4 +669,3 @@ float serverflags; .float misc_bulletcounter; // replaces uzi & hlac bullet counter. void PlayerUseKey(); -