]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_nix.qc
Get rid of if not, step 1.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_nix.qc
index 45aa9d14b09ad798a8b57c087471fd2c4d1863f0..dc12b05209eccc70baa32187ab62b033eb8fb961 100644 (file)
@@ -13,18 +13,20 @@ float NIX_CanChooseWeapon(float wpn)
 {
        entity e;
        e = get_weaponinfo(wpn);
-       if(!e.weapons) // skip dummies
+       if(!e.weapon) // skip dummies
                return FALSE;
        if(g_weaponarena)
        {
-               if not(g_weaponarena & e.weapons)
+               if(!(g_weaponarena_weapons & WepSet_FromWeapon(wpn)))
                        return FALSE;
        }
        else
        {
                if(wpn == WEP_LASER && g_nix_with_laser)
                        return FALSE;
-               if not(e.spawnflags & WEP_FLAG_NORMAL)
+               if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
+                       return FALSE;
+               if (!(e.spawnflags & WEP_FLAG_NORMAL))
                        return FALSE;
        }
        return TRUE;
@@ -94,7 +96,7 @@ void NIX_GiveCurrentWeapon()
                if(dt >= 1 && dt <= 5)
                        self.nix_lastinfotime = -42;
                else
-                       Send_CSQC_Centerprint_Generic(self, CPID_NIX_WPNCHANGE, strcat("^2Active weapon: ^3", W_Name(nix_weapon)), 0, 0);
+                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_NEWWEAPON, nix_weapon);
 
                weapon_action(nix_weapon, WR_RESETPLAYER);
 
@@ -116,7 +118,7 @@ void NIX_GiveCurrentWeapon()
        {
                self.nix_lastinfotime = dt; // initial value 0 should count as "not seen"
                if(dt >= 1 && dt <= 5)
-                       Send_CSQC_Centerprint_Generic(self, CPID_NIX_WPNCHANGE, strcat("^3%d^2 seconds until weapon change...\n\nNext weapon: ^3", W_Name(nix_nextweapon)), 1, dt);
+                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_COUNTDOWN, nix_nextweapon, dt);
        }
 
        if(!(self.items & IT_UNLIMITED_WEAPON_AMMO) && time > self.nix_nextincr)
@@ -134,10 +136,10 @@ void NIX_GiveCurrentWeapon()
                self.nix_nextincr = time + autocvar_g_balance_nix_incrtime;
        }
 
-       self.weapons = 0;
+       self.weapons = '0 0 0';
        if(g_nix_with_laser)
-               WEPSET_ANDNOT_EW(self, WEP_LASER);
-       WEPSET_OR_EW(self, nix_weapon);
+               self.weapons &= ~WEPSET_LASER;
+       self.weapons |= WepSet_FromWeapon(nix_weapon);
 
        if(self.switchweapon != nix_weapon)
                if(!client_hasweapon(self, self.switchweapon, TRUE, FALSE))
@@ -158,15 +160,6 @@ MUTATOR_HOOKFUNCTION(nix_ForbidThrowCurrentWeapon)
        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");
@@ -212,7 +205,7 @@ MUTATOR_HOOKFUNCTION(nix_PlayerPreThink)
 {
        if(!intermission_running)
        if(self.deadflag == DEAD_NO)
-       if(self.classname == "player")
+       if(IS_PLAYER(self))
                NIX_GiveCurrentWeapon();
        return 0;
 }
@@ -225,18 +218,24 @@ MUTATOR_HOOKFUNCTION(nix_PlayerSpawn)
        return 0;
 }
 
+MUTATOR_HOOKFUNCTION(nix_SetModname)
+{
+       modname = "NIX";
+       return 0;
+}
+
 MUTATOR_DEFINITION(mutator_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);
        MUTATOR_HOOK(OnEntityPreSpawn, nix_OnEntityPreSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerPreThink, nix_PlayerPreThink, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerSpawn, nix_PlayerSpawn, CBC_ORDER_ANY);
+       MUTATOR_HOOK(SetModname, nix_SetModname, CBC_ORDER_LAST);
 
        MUTATOR_ONADD
        {
@@ -248,6 +247,11 @@ MUTATOR_DEFINITION(mutator_nix)
                NIX_precache();
        }
 
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // nothing to roll back
+       }
+
        MUTATOR_ONREMOVE
        {
                // as the PlayerSpawn hook will no longer run, NIX is turned off by this!
@@ -259,7 +263,7 @@ MUTATOR_DEFINITION(mutator_nix)
                        e.ammo_nails = start_ammo_nails;
                        e.ammo_rockets = start_ammo_rockets;
                        e.ammo_fuel = start_ammo_fuel;
-                       WEPSET_COPY_EA(e, start_weapons);
+                       e.weapons = start_weapons;
                        if(!client_hasweapon(e, e.weapon, TRUE, FALSE))
                                e.switchweapon = w_getbestweapon(self);
                }