]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Minor cleanup to nades mutator
authorMario <mario.mario@y7mail.com>
Sun, 18 Oct 2020 10:27:42 +0000 (20:27 +1000)
committerMario <mario.mario@y7mail.com>
Sun, 18 Oct 2020 10:27:42 +0000 (20:27 +1000)
qcsrc/common/mutators/mutator/nades/nades.qc

index 1c37195a35498ff4140c9ac1a52c7cd753b8541a..66d9e2d2c327227c69bf508e77e70a5f1ea11b50 100644 (file)
@@ -505,22 +505,20 @@ void nade_translocate_boom(entity this)
 
 void nade_spawn_boom(entity this)
 {
+       entity player = this.realowner;
        entity spawnloc = new(nade_spawn_loc);
        setorigin(spawnloc, this.origin);
-       setsize(spawnloc, this.realowner.mins, this.realowner.maxs);
+       setsize(spawnloc, player.mins, player.maxs);
        set_movetype(spawnloc, MOVETYPE_NONE);
        spawnloc.solid = SOLID_NOT;
-       spawnloc.drawonlytoclient = this.realowner;
+       spawnloc.drawonlytoclient = player;
        spawnloc.effects = EF_STARDUST;
        spawnloc.cnt = autocvar_g_nades_spawn_count;
 
-       if(this.realowner.nade_spawnloc)
-       {
-               delete(this.realowner.nade_spawnloc);
-               this.realowner.nade_spawnloc = NULL;
-       }
+       if(player.nade_spawnloc)
+               delete(player.nade_spawnloc);
 
-       this.realowner.nade_spawnloc = spawnloc;
+       player.nade_spawnloc = spawnloc;
 }
 
 void nades_orb_think(entity this)
@@ -940,7 +938,8 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
        entity _nade = e.nade;
        e.nade = NULL;
 
-       delete(e.fake_nade);
+       if(e.fake_nade)
+               delete(e.fake_nade);
        e.fake_nade = NULL;
 
        Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
@@ -1128,15 +1127,17 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin
 
 void nade_prime(entity this)
 {
-       if(autocvar_g_nades_bonus_only)
-       if(!STAT(NADE_BONUS, this))
+       if(autocvar_g_nades_bonus_only && !STAT(NADE_BONUS, this))
                return; // only allow bonus nades
 
+       // TODO: handle old nade if it exists?
        if(this.nade)
                delete(this.nade);
+       this.nade = NULL;
 
        if(this.fake_nade)
                delete(this.fake_nade);
+       this.fake_nade = NULL;
 
        int ntype;
        string pntype = this.pokenade_type;
@@ -1160,22 +1161,7 @@ void nade_prime(entity this)
 
 bool CanThrowNade(entity this)
 {
-       if(this.vehicle)
-               return false;
-
-       if(IS_DEAD(this))
-               return false;
-
-       if (!autocvar_g_nades)
-               return false; // allow turning them off mid match
-
-       if (weaponLocked(this))
-               return false;
-
-       if (!IS_PLAYER(this))
-               return false;
-
-       return true;
+       return !(this.vehicle || !autocvar_g_nades || IS_DEAD(this) || !IS_PLAYER(this) || weaponLocked(this));
 }
 
 .bool nade_altbutton;