]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow maps and player models to require beating a campaign or reaching a given level... mirceakitsune/campaign_unlock
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 22 Dec 2019 15:28:08 +0000 (17:28 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 22 Dec 2019 15:34:14 +0000 (17:34 +0200)
qcsrc/common/mapinfo.qc
qcsrc/common/mapinfo.qh
qcsrc/common/util.qc
qcsrc/common/util.qh
qcsrc/menu/xonotic/playermodel.qc
xonotic-server.cfg

index 1d6f4897b81df2ea81f0ee9638c9d93e44172c52..b372339f2d3d3a4b9cb87544aa0c5a11a69915e3 100644 (file)
@@ -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
index b669ba1f7b63aa2a8c74ab7bc7e1f91caaed1de3..a3a198464f3003403fe1921b23921c8fd642c36f 100644 (file)
@@ -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;
 
index d9b9efcde36444c8d06b804b5dd60ad80c0ec237..33d5131c840a12c99e4a07fd1146ed6399635297 100644 (file)
@@ -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);
        }
index 756e02cf51ffeb8aa85970233bfe7007d60818b9..364fd7e1b6280d1970daa73c2c652b3e4b82ba56 100644 (file)
@@ -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;
index 08518d1312a6fd3f59351ca38fcc8daa229c9a8d..6fa1bcc8543ce3e4625f4ec03ce60ff147f680dc 100644 (file)
@@ -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)));
index 4e9685ba43e4e254a97925dbd721d733c3165d25..4ac4a095628e23599a3f552fb19ed824634394af 100644 (file)
@@ -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)"