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);
+}
{
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);
}
// 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;
}
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);
}
}