]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/miscfunctions.qc
Added random start weapons.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qc
index ffc0e9ea568cbd65278a5f050a6f8d1babd91404..1abcf850c46e44219a90e223394e023adbf0c583 100644 (file)
@@ -292,37 +292,37 @@ Called with:
   0:  sends the request
   >0: receives a cvar from name=argv(f) value=argv(f+1)
 */
-void GetCvars_handleString(entity this, string thisname, float f, .string field, string name)
+void GetCvars_handleString(entity this, entity store, string thisname, float f, .string field, string name)
 {
        if (f < 0)
        {
-               if (this.(field))
-                       strunzone(this.(field));
-               this.(field) = string_null;
+               if (store.(field))
+                       strunzone(store.(field));
+               store.(field) = string_null;
        }
        else if (f > 0)
        {
                if (thisname == name)
                {
-                       if (this.(field))
-                               strunzone(this.(field));
-                       this.(field) = strzone(argv(f + 1));
+                       if (store.(field))
+                               strunzone(store.(field));
+                       store.(field) = strzone(argv(f + 1));
                }
        }
        else
                stuffcmd(this, strcat("cl_cmd sendcvar ", name, "\n"));
 }
-void GetCvars_handleString_Fixup(entity this, string thisname, float f, .string field, string name, string(entity, string) func)
+void GetCvars_handleString_Fixup(entity this, entity store, string thisname, float f, .string field, string name, string(entity, string) func)
 {
-       GetCvars_handleString(this, thisname, f, field, name);
+       GetCvars_handleString(this, store, thisname, f, field, name);
        if (f >= 0) // also initialize to the fitting value for "" when sending cvars out
                if (thisname == name)
                {
-                       string s = func(this, strcat1(this.(field)));
-                       if (s != this.(field))
+                       string s = func(this, strcat1(store.(field)));
+                       if (s != store.(field))
                        {
-                               strunzone(this.(field));
-                               this.(field) = strzone(s);
+                               strunzone(store.(field));
+                               store.(field) = strzone(s);
                        }
                }
 }
@@ -339,7 +339,7 @@ void GetCvars_handleFloat(entity this, entity store, string thisname, float f, .
        else
                stuffcmd(this, strcat("cl_cmd sendcvar ", name, "\n"));
 }
-void GetCvars_handleFloatOnce(entity this, string thisname, float f, .float field, string name)
+void GetCvars_handleFloatOnce(entity this, entity store, string thisname, float f, .float field, string name)
 {
        if (f < 0)
        {
@@ -348,17 +348,17 @@ void GetCvars_handleFloatOnce(entity this, string thisname, float f, .float fiel
        {
                if (thisname == name)
                {
-                       if (!this.(field))
+                       if (!store.(field))
                        {
-                               this.(field) = stof(argv(f + 1));
-                               if (!this.(field))
-                                       this.(field) = -1;
+                               store.(field) = stof(argv(f + 1));
+                               if (!store.(field))
+                                       store.(field) = -1;
                        }
                }
        }
        else
        {
-               if (!this.(field))
+               if (!store.(field))
                        stuffcmd(this, strcat("cl_cmd sendcvar ", name, "\n"));
        }
 }
@@ -408,7 +408,7 @@ REPLICATE(cvar_g_xonoticversion, string, "g_xonoticversion");
 /**
  * @param f -1: cleanup, 0: request, 1: receive
  */
-void GetCvars(entity this, int f)
+void GetCvars(entity this, entity store, int f)
 {
        string s = string_null;
 
@@ -421,21 +421,21 @@ void GetCvars(entity this, int f)
 
        Notification_GetCvars(this);
 
-       ReplicateVars(this, s, f);
+       ReplicateVars(this, store, s, f);
 
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriority, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[0], "cl_weaponpriority0", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[1], "cl_weaponpriority1", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[2], "cl_weaponpriority2", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[3], "cl_weaponpriority3", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[4], "cl_weaponpriority4", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[5], "cl_weaponpriority5", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[6], "cl_weaponpriority6", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[7], "cl_weaponpriority7", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[8], "cl_weaponpriority8", W_FixWeaponOrder_AllowIncomplete);
-       GetCvars_handleString_Fixup(this, s, f, cvar_cl_weaponpriorities[9], "cl_weaponpriority9", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriority, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[0], "cl_weaponpriority0", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[1], "cl_weaponpriority1", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[2], "cl_weaponpriority2", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[3], "cl_weaponpriority3", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[4], "cl_weaponpriority4", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[5], "cl_weaponpriority5", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[6], "cl_weaponpriority6", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[7], "cl_weaponpriority7", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[8], "cl_weaponpriority8", W_FixWeaponOrder_AllowIncomplete);
+       GetCvars_handleString_Fixup(this, store, s, f, cvar_cl_weaponpriorities[9], "cl_weaponpriority9", W_FixWeaponOrder_AllowIncomplete);
 
-       GetCvars_handleFloat(this, this, s, f, cvar_cl_allow_uidtracking, "cl_allow_uidtracking");
+       GetCvars_handleFloat(this, store, s, f, cvar_cl_allow_uidtracking, "cl_allow_uidtracking");
 
        // fixup of switchweapon (needed for LMS or when spectating is disabled, as PutClientInServer comes too early)
        if (f > 0)
@@ -643,6 +643,12 @@ void readplayerstartcvars()
                start_ammo_cells = cvar("g_start_ammo_cells");
                start_ammo_plasma = cvar("g_start_ammo_plasma");
                start_ammo_fuel = cvar("g_start_ammo_fuel");
+               num_random_start_weapons = cvar("g_num_random_start_weapons");
+               random_start_shells = cvar("g_random_start_shells");
+               random_start_bullets = cvar("g_random_start_bullets");
+               random_start_rockets = cvar("g_random_start_rockets");
+               random_start_cells = cvar("g_random_start_cells");
+               random_start_plasma = cvar("g_random_start_plasma");
        }
 
        if (warmup_stage)
@@ -711,6 +717,11 @@ void readplayerstartcvars()
        start_ammo_cells = max(0, start_ammo_cells);
        start_ammo_plasma = max(0, start_ammo_plasma);
        start_ammo_fuel = max(0, start_ammo_fuel);
+       random_start_shells = max(0, random_start_shells);
+       random_start_bullets = max(0, random_start_bullets);
+       random_start_rockets = max(0, random_start_rockets);
+       random_start_cells = max(0, random_start_cells);
+       random_start_plasma = max(0, random_start_plasma);
 
        warmup_start_ammo_shells = max(0, warmup_start_ammo_shells);
        warmup_start_ammo_nails = max(0, warmup_start_ammo_nails);