float g_weaponspreadfactor;
WEPSET_DECLARE_A(start_weapons);
+WEPSET_DECLARE_A(start_weapons_default);
+WEPSET_DECLARE_A(start_weapons_defaultmask);
float start_items;
float start_ammo_shells;
float start_ammo_nails;
float start_health;
float start_armorvalue;
WEPSET_DECLARE_A(warmup_start_weapons);
+WEPSET_DECLARE_A(warmup_start_weapons_default);
+WEPSET_DECLARE_A(warmup_start_weapons_defaultmask);
float warmup_start_ammo_shells;
float warmup_start_ammo_nails;
float warmup_start_ammo_rockets;
float want_weapon(string cvarprefix, entity weaponinfo, float allguns)
{
var float i = weaponinfo.weapon;
+ var float d = 0;
if (!i)
return 0;
- var float t = cvar(strcat(cvarprefix, weaponinfo.netname));
+ if (g_lms || g_ca || allguns)
+ d = (weaponinfo.spawnflags & WEP_FLAG_NORMAL);
+ else if(t < -1)
+ d = 0;
+ else if (g_cts)
+ d = (i == WEP_SHOTGUN);
+ else if (g_nexball)
+ d = 0; // weapon is set a few lines later
+ else
+ d = (i == WEP_LASER || i == WEP_SHOTGUN);
+ if(g_grappling_hook) // if possible, redirect off-hand hook to on-hand hook
+ d |= (i == WEP_HOOK);
- if (t < 0) // "default" weapon selection
- {
- if (g_lms || g_ca || allguns)
- t = (weaponinfo.spawnflags & WEP_FLAG_NORMAL);
- else if(t < -1)
- t = 0;
- else if (g_cts)
- t = (i == WEP_SHOTGUN);
- else if (g_nexball)
- t = 0; // weapon is set a few lines later
- else
- t = (i == WEP_LASER || i == WEP_SHOTGUN);
- if(g_grappling_hook) // if possible, redirect off-hand hook to on-hand hook
- t |= (i == WEP_HOOK);
- }
+ var float t = cvar(strcat(cvarprefix, weaponinfo.netname));
+
+ // bit order in t:
+ // 1: want or not
+ // 2: is default?
+ // 4: is set by default?
+ if(t < 0)
+ t = 4 | (3 * d);
+ else
+ t |= (2 * d);
return t;
}
// initialize starting values for players
WEPSET_CLEAR_A(start_weapons);
+ WEPSET_CLEAR_A(start_weapons_default);
+ WEPSET_CLEAR_A(start_weapons_defaultmask);
start_items = 0;
start_ammo_shells = 0;
start_ammo_nails = 0;
for (i = WEP_FIRST; i <= WEP_LAST; ++i)
{
e = get_weaponinfo(i);
- if(want_weapon("g_start_weapon_", e, FALSE))
+ w = want_weapon("g_start_weapon_", e, FALSE);
+ if(w & 1)
WEPSET_OR_AW(start_weapons, i);
+ if(w & 2)
+ WEPSET_OR_AW(start_weapons_default, i);
+ if(w & 4)
+ WEPSET_OR_AW(start_weapons_defaultmask, i);
}
}
warmup_start_health = start_health;
warmup_start_armorvalue = start_armorvalue;
WEPSET_COPY_AA(warmup_start_weapons, start_weapons);
+ WEPSET_COPY_AA(warmup_start_weapons_default, start_weapons_default);
+ WEPSET_COPY_AA(warmup_start_weapons_defaultmask, start_weapons_defaultmask);
if (!g_weaponarena && !g_minstagib && !g_ca)
{
for (i = WEP_FIRST; i <= WEP_LAST; ++i)
{
e = get_weaponinfo(i);
- if(want_weapon("g_start_weapon_", e, cvar("g_warmup_allguns")))
+ w = want_weapon("g_start_weapon_", e, cvar("g_warmup_allguns"));
+ if(w & 1)
WEPSET_OR_AW(warmup_start_weapons, i);
+ if(w & 2)
+ WEPSET_OR_AW(warmup_start_weapons_default, i);
+ if(w & 4)
+ WEPSET_OR_AW(warmup_start_weapons_defaultmask, i);
}
}
}
- if (g_jetpack || (g_grappling_hook && WEPSET_CONTAINS_AW(start_weapons, WEP_HOOK)))
+ if (g_jetpack)
+ start_items |= IT_JETPACK;
+
+ MUTATOR_CALLHOOK(SetStartItems);
+
+ if ((start_items & IT_JETPACK) || (g_grappling_hook && WEPSET_CONTAINS_AW(start_weapons, WEP_HOOK)))
{
g_grappling_hook = 0; // these two can't coexist, as they use the same button
start_items |= IT_FUEL_REGEN;
warmup_start_ammo_fuel = max(warmup_start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
}
- if (g_jetpack)
- start_items |= IT_JETPACK;
-
- MUTATOR_CALLHOOK(SetStartItems);
-
for (i = WEP_FIRST; i <= WEP_LAST; ++i)
{
e = get_weaponinfo(i);
In "replace all" mode, e.g. Nex will have the default replacement "rifle".
In "replace random" mode, Nex will have the default replacement "nex rifle".
+This mutator's replacements run BEFORE regular weaponreplace!
+
The New Toys guns do NOT get a spawn function, so they can only ever be spawned
when this mutator is active.
roflsound "New toys, new toys!" sound.
*/
+
+string i_herd_yo_liek_weaponreplace(string replacement)
+{
+ string newlist;
+ float n = tokenize_console(replacement);
+ string out = "";
+ for(i = 0; i < n; ++i)
+ {
+ string s = argv(i);
+ string r = cvar_string(strcat("g_weaponreplace_", s));
+ if(r == "")
+ out = strcat(out, " ", s);
+ else if(r != "0")
+ out = strcat(out, " ", r);
+ }
+ return substring(out, 1);
+}
+
+MUTATOR_HOOKFUNCTION(nt_SetModname)
+{
+ modname = "NewToys";
+ return 0;
+}
+
+MUTATOR_HOOKFUNCTION(nt_SetStartItems)
+{
+ // rearrange start_weapon_default
+ // apply those bits that are set by start_weapon_defaultmask
+ // same for warmup
+ // TODO
+ return 0;
+}
+
+MUTATOR_DEFINITION(mutator_new_toys)
+{
+ MUTATOR_HOOK(SetModname, nt_SetModname, CBC_ORDER_ANY);
+ MUTATOR_HOOK(SetStartItems, nix_SetStartItems, CBC_ORDER_ANY);
+
+ MUTATOR_ONADD
+ {
+ if(time > 1) // game loads at time 1
+ error("This cannot be added at runtime\n");
+ }
+ MUTATOR_ONREMOVE
+ {
+ error("This cannot be removed at runtime\n");
+ }
+
+ return 0;
+}
return 1; // no throwing in NIX
}
-MUTATOR_HOOKFUNCTION(nix_SetStartItems)
-{
- NIX_precache();
- // we do NOT change the start weapons any more, so we can later turn off the mutator!
- // start_weapons = 0; // will be done later, when player spawns
- // warmup_start_weapons = 0; // will be done later, when player spawns
- return 0;
-}
-
MUTATOR_HOOKFUNCTION(nix_BuildMutatorsString)
{
ret_string = strcat(ret_string, ":NIX");
entity e;
MUTATOR_HOOK(ForbidThrowCurrentWeapon, nix_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
- MUTATOR_HOOK(SetStartItems, nix_SetStartItems, CBC_ORDER_EXCLUSIVE);
MUTATOR_HOOK(BuildMutatorsString, nix_BuildMutatorsString, CBC_ORDER_ANY);
MUTATOR_HOOK(BuildMutatorsPrettyString, nix_BuildMutatorsPrettyString, CBC_ORDER_ANY);
MUTATOR_HOOK(FilterItem, nix_FilterItem, CBC_ORDER_ANY);