From: Mario Date: Sun, 18 Oct 2020 10:27:42 +0000 (+1000) Subject: Minor cleanup to nades mutator X-Git-Tag: xonotic-v0.8.5~725 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2ad7a79250d682efda53246cb74df7cf7d55dd82;p=xonotic%2Fxonotic-data.pk3dir.git Minor cleanup to nades mutator --- diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 1c37195a3..66d9e2d2c 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -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;