Merge branch 'master' into Mario/weaponarena_available
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qc
index bc0b49ca027ece50fb41bbccc35723b3252886d7..aa5146419a0be981ff96246e70112d3dc47f83fc 100644 (file)
@@ -522,6 +522,22 @@ float want_weapon(entity weaponinfo, float allguns) // WEAPONTODO: what still ne
        return t;
 }
 
+void weaponarena_available_update(entity this)
+{
+       if(!weaponsInMap)
+       {
+               // if no weapons are available, just fall back to most weapons arena
+               FOREACH(Weapons, it != WEP_Null, {
+                       if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && (it.spawnflags & WEP_FLAG_NORMAL) && !(it.spawnflags & WEP_FLAG_HIDDEN))
+                               g_weaponarena_weapons |= (it.m_wepset);
+               });
+               start_weapons = g_weaponarena_weapons;
+               return;
+       }
+       g_weaponarena_weapons |= weaponsInMap;
+       start_weapons = g_weaponarena_weapons;
+}
+
 void readplayerstartcvars()
 {
        float i, t;
@@ -587,6 +603,18 @@ void readplayerstartcvars()
                                g_weaponarena_weapons |= (it.m_wepset);
                });
        }
+       else if (s == "available")
+       {
+               g_weaponarena = 2;
+               g_weaponarena_list = "Most Weapons";
+               // include weapons the player would start with
+               FOREACH(Weapons, it != WEP_Null, {
+                       int w = want_weapon(it, false);
+                       if(w & 1)
+                               g_weaponarena_weapons |= (it.m_wepset);
+               });
+               InitializeEntity(NULL, weaponarena_available_update, INITPRIO_FINDTARGET);
+       }
        else if (s == "none")
        {
                g_weaponarena = 1;