]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
remove even more evil
authorRudolf Polzer <divverent@alientrap.org>
Sun, 4 Mar 2012 17:12:49 +0000 (18:12 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Sun, 4 Mar 2012 17:12:49 +0000 (18:12 +0100)
qcsrc/common/items.qc
qcsrc/common/items.qh
qcsrc/server/cl_client.qc
qcsrc/server/g_damage.qc
qcsrc/server/t_items.qc

index 3ddf8099f51c0736471859939a61b79b97e21df6..d7293ef69d53fe15aac7e31c079125efd2322d28 100644 (file)
@@ -154,3 +154,21 @@ string W_FixWeaponOrder_ForceComplete(string order)
        return W_FixWeaponOrder(order, 1);
 }
 
+void W_RandomWeapons(entity e, float n)
+{
+       float i, j;
+       WEPSET_DECLARE_A(remaining);
+       WEPSET_DECLARE_A(result);
+       WEPSET_COPY_AE(remaining, e);
+       WEPSET_CLEAR_A(result);
+       for(i = 0; i < n; ++i)
+       {
+               RandomSelection_Init();
+               for(j = WEP_FIRST; j <= WEP_LAST; ++j)
+                       if(WEPSET_CONTAINS_AW(remaining, j))
+                               RandomSelection_Add(world, j, string_null, 1, 1);
+               WEPSET_OR_AW(result, RandomSelection_chosen_float);
+               WEPSET_ANDNOT_AW(remaining, RandomSelection_chosen_float);
+       }
+       WEPSET_COPY_EA(e, result);
+}
index 89d2419ffbd3d71d2e5fcf715399c4a7780b0c31..6159291192b209f740ff14d340269b40d7c8d66f 100644 (file)
@@ -190,3 +190,5 @@ string W_NameWeaponOrder(string order);
 string W_FixWeaponOrder_BuildImpulseList(string o);
 string W_FixWeaponOrder_AllowIncomplete(string order);
 string W_FixWeaponOrder_ForceComplete(string order);
+
+void W_RandomWeapons(entity e, float n);
index 9c842d7c25f535a2e3b57fa599926fc6f8499f07..f34e22b0d9a15224940df81013b852c705091e33 100644 (file)
@@ -758,7 +758,7 @@ void PutClientInServer (void)
                {
                        if(g_weaponarena_random_with_laser)
                                WEPSET_ANDNOT_EW(self, WEP_LASER);
-                       self.weapons = randombits(self.weapons, g_weaponarena_random, FALSE);
+                       W_RandomWeapons(self, g_weaponarena_random);
                        if(g_weaponarena_random_with_laser)
                                WEPSET_OR_EW(self, WEP_LASER);
                }
index ef3b45aec54095bd5f050655671c11d8e099b5e1..59da8e086f3e148131bf13480ca22cd180230808 100644 (file)
@@ -101,10 +101,9 @@ void UpdateFrags(entity player, float f)
 
 // NOTE: f=0 means still count as a (positive) kill, but count no frags for it
 void W_SwitchWeapon_Force(entity e, float w);
+entity GiveFrags_randomweapons;
 void GiveFrags (entity attacker, entity targ, float f, float deathtype)
 {
-       WEPSET_DECLARE_A(w);
-
        // TODO route through PlayerScores instead
        if(gameover) return;
 
@@ -150,20 +149,27 @@ void GiveFrags (entity attacker, entity targ, float f, float deathtype)
                }
                else
                {
+                       if(!GiveFrags_randomweapons)
+                       {
+                               GiveFrags_randomweapons = spawn();
+                               GiveFrags_randomweapons.classname = "GiveFrags_randomweapons";
+                       }
+
                        if(inWarmupStage)
-                               WEPSET_COPY_AA(w, warmup_start_weapons);
+                               WEPSET_COPY_EA(GiveFrags_randomweapons, warmup_start_weapons);
                        else
-                               WEPSET_COPY_AA(w, start_weapons);
+                               WEPSET_COPY_EA(GiveFrags_randomweapons, start_weapons);
 
                        // all others (including the culprit): remove
-                       WEPSET_ANDNOT_AE(w, attacker);
-                       WEPSET_ANDNOT_AW(w, culprit);
+                       WEPSET_ANDNOT_EE(GiveFrags_randomweapons, attacker);
+                       WEPSET_ANDNOT_EW(GiveFrags_randomweapons, culprit);
 
                        // among the remaining ones, choose one by random
-                       _WS_w = randombits(_WS_w, 1, FALSE); // FIXME
-                       if(!WEPSET_EMPTY_A(w))
+                       W_RandomWeapons(GiveFrags_randomweapons, 1);
+
+                       if(!WEPSET_EMPTY_E(GiveFrags_randomweapons))
                        {
-                               WEPSET_OR_EA(attacker, w);
+                               WEPSET_OR_EE(attacker, GiveFrags_randomweapons);
                                WEPSET_ANDNOT_EW(attacker, culprit);
                        }
                }
index c62601cc6c943065bdfc9b1199622aa4070c7b15..288f1bbb811e14c99fe558fd2e14491a1a381b55 100644 (file)
@@ -348,7 +348,6 @@ float Item_GiveTo(entity item, entity player)
        float pickedup;
        float it;
        float i;
-       entity e;
 
        // if nothing happens to player, just return without taking the item
        pickedup = FALSE;