From: Mircea Kitsune Date: Sun, 22 Dec 2019 15:28:08 +0000 (+0200) Subject: Allow maps and player models to require beating a campaign or reaching a given level... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fheads%2Fmirceakitsune%2Fcampaign_unlock;p=xonotic%2Fxonotic-data.pk3dir.git Allow maps and player models to require beating a campaign or reaching a given level in order to be unlocked (appear in the menu) --- diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index 1d6f4897b..b372339f2 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -905,6 +905,23 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gamet else if(WARN_COND) LOG_WARN("Map ", pFilename, " supports unknown feature ", t, ", ignored"); } + else if(t == "locked") + { + t = car(s); s = cdr(s); f = stof(s); + // hide the map based on campaign status + if(f > 0) + { + // we need to have reached this level + if(cvar(strcat("g_campaign_", t, "_index")) < f); + f |= MAPINFO_FLAG_LOCKED; + } + else + { + // we need to have won the campaign + if(!cvar(strcat("g_campaign_", t, "_won"))); + f |= MAPINFO_FLAG_LOCKED; + } + } else if(t == "hidden") { MapInfo_Map_flags |= MAPINFO_FLAG_HIDDEN; @@ -1313,6 +1330,11 @@ int MapInfo_ForbiddenFlags() { int f = MAPINFO_FLAG_FORBIDDEN; +#ifdef GAMEQC + if (!cvar("g_maplist_allow_locked")) +#endif + f |= MAPINFO_FLAG_LOCKED; + #ifdef GAMEQC if (!cvar("g_maplist_allow_hidden")) #endif diff --git a/qcsrc/common/mapinfo.qh b/qcsrc/common/mapinfo.qh index b669ba1f7..a3a198464 100644 --- a/qcsrc/common/mapinfo.qh +++ b/qcsrc/common/mapinfo.qh @@ -612,10 +612,11 @@ const int MAPINFO_FEATURE_VEHICLES = 2; const int MAPINFO_FEATURE_TURRETS = 4; const int MAPINFO_FEATURE_MONSTERS = 8; -const int MAPINFO_FLAG_HIDDEN = 1; // not in lsmaps/menu/vcall/etc., can just be changed to manually -const int MAPINFO_FLAG_FORBIDDEN = 2; // don't even allow the map by a cvar setting that allows hidden maps -const int MAPINFO_FLAG_FRUSTRATING = 4; // this map is near impossible to play, enable at your own risk -const int MAPINFO_FLAG_NOAUTOMAPLIST = 8; // do not include when automatically building maplist (counts as hidden for maplist building purposes) +const int MAPINFO_FLAG_LOCKED = 1; // same as hidden but unlocked by a campaign +const int MAPINFO_FLAG_HIDDEN = 2; // not in lsmaps/menu/vcall/etc., can just be changed to manually +const int MAPINFO_FLAG_FORBIDDEN = 4; // don't even allow the map by a cvar setting that allows hidden maps +const int MAPINFO_FLAG_FRUSTRATING = 8; // this map is near impossible to play, enable at your own risk +const int MAPINFO_FLAG_NOAUTOMAPLIST = 16; // do not include when automatically building maplist (counts as hidden for maplist building purposes) float MapInfo_count; diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index d9b9efcde..33d5131c8 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -1330,6 +1330,8 @@ float get_model_parameters(string m, float sk) get_model_parameters_bone_aimweight[i] = 0; } get_model_parameters_fixbone = 0; + get_model_parameters_locked_name = string_null; + get_model_parameters_locked_level = 0; get_model_parameters_hidden = false; #ifdef GAMEQC @@ -1413,6 +1415,11 @@ float get_model_parameters(string m, float sk) } if(c == "fixbone") get_model_parameters_fixbone = stof(s); + if(c == "locked") + { + get_model_parameters_locked_name = car(s); + get_model_parameters_locked_level = stof(cdr(s)); + } if(c == "hidden") get_model_parameters_hidden = stob(s); } diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index 756e02cf5..364fd7e1b 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -145,6 +145,8 @@ float get_model_parameters_species; string get_model_parameters_sex; float get_model_parameters_weight; float get_model_parameters_age; +string get_model_parameters_locked_name; // campaign name +float get_model_parameters_locked_level; // campaign level bool get_model_parameters_hidden; string get_model_parameters_description; string get_model_parameters_bone_upperbody; diff --git a/qcsrc/menu/xonotic/playermodel.qc b/qcsrc/menu/xonotic/playermodel.qc index 08518d131..6fa1bcc85 100644 --- a/qcsrc/menu/xonotic/playermodel.qc +++ b/qcsrc/menu/xonotic/playermodel.qc @@ -22,6 +22,19 @@ void XonoticPlayerModelSelector_configureXonoticPlayerModelSelector(entity me) me.configureXonoticImage(me, string_null, -1); } +bool XonoticPlayerModelSelector_loadModels_isLocked() +{ + bool hidden = false; // hide the player model based on campaign status + if(get_model_parameters_locked_name) + { + if(get_model_parameters_locked_level > 0) // we need to have reached this level + hidden = cvar(strcat("g_campaign_", get_model_parameters_locked_name, "_index")) < get_model_parameters_locked_level; + else // we need to have won the campaign + hidden = !cvar(strcat("g_campaign_", get_model_parameters_locked_name, "_won")); + } + return hidden; +} + void XonoticPlayerModelSelector_loadModels(entity me) { int i; @@ -38,7 +51,7 @@ void XonoticPlayerModelSelector_loadModels(entity me) fn = search_getfilename(glob, i); if(!get_model_parameters(fn, -1)) continue; - if(get_model_parameters_hidden) + if(get_model_parameters_hidden || XonoticPlayerModelSelector_loadModels_isLocked()) continue; bufstr_add(sortbuf, sprintf("%-128s%s", get_model_parameters_name, fn), 1); } @@ -51,7 +64,7 @@ void XonoticPlayerModelSelector_loadModels(entity me) fn = substring(bufstr_get(sortbuf, i), 128, -1); if(!get_model_parameters(fn, -1)) error("But it JUST worked!"); - if(get_model_parameters_hidden) + if(get_model_parameters_hidden || XonoticPlayerModelSelector_loadModels_isLocked()) continue; bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_TITLE, get_model_parameters_name); bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_IMAGE, strcat("/", substring(get_model_datafilename(get_model_parameters_modelname, get_model_parameters_modelskin, "tga"), 0, -5))); diff --git a/xonotic-server.cfg b/xonotic-server.cfg index 4e9685ba4..4ac4a0956 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -411,6 +411,7 @@ sv_allowdownloads 0 // download protocol is evil set g_jump_grunt 0 "Do you make a grunting noise every time you jump? Is it the same grunting noise every time?" +set g_maplist_allow_locked 1 "allow locked maps to be, e.g., voted for and in the maplist" set g_maplist_allow_hidden 0 "allow hidden maps to be, e.g., voted for and in the maplist" set g_maplist_allow_frustrating 0 "allow impossible maps to be, e.g., voted for and in the maplist (if set to 2, ONLY impossible maps are allowed)"