X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftrigger%2Fgravity.qc;h=b6824ec2c82660dd8dcc546539c04fb034667356;hb=cf41044c9d897080866da6e0ca39d807e094e23e;hp=3ea1562f084a93e4c73b7fdb0c9a26ac64dad90e;hpb=65e9ceb03c81bc515d090a54f65dd620c8c6dc43;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/trigger/gravity.qc b/qcsrc/common/triggers/trigger/gravity.qc index 3ea1562f0..b6824ec2c 100644 --- a/qcsrc/common/triggers/trigger/gravity.qc +++ b/qcsrc/common/triggers/trigger/gravity.qc @@ -3,14 +3,13 @@ .entity trigger_gravity_check; void trigger_gravity_remove(entity own) { - if(own.trigger_gravity_check.owner == own) - { + if (own.trigger_gravity_check.owner == own) { UpdateCSQCProjectile(own); own.gravity = own.trigger_gravity_check.gravity; delete(own.trigger_gravity_check); - } - else + } else { backtrace("Removing a trigger_gravity_check with no valid owner"); + } own.trigger_gravity_check = NULL; } void trigger_gravity_check_think(entity this) @@ -18,16 +17,14 @@ void trigger_gravity_check_think(entity this) // This spawns when a player enters the gravity zone and checks if he left. // Each frame, this.count is set to 2 by trigger_gravity_touch() and decreased by 1 here. // It the player has left the gravity trigger, this will be allowed to reach 0 and indicate that. - if(this.count <= 0) - { - if(this.owner.trigger_gravity_check == this) + if (this.count <= 0) { + if (this.owner.trigger_gravity_check == this) { trigger_gravity_remove(this.owner); - else + } else { delete(this); + } return; - } - else - { + } else { this.count -= 1; this.nextthink = time; } @@ -42,29 +39,28 @@ void trigger_gravity_touch(entity this, entity toucher) { float g; - if(this.state != true) + if (this.state != true) { return; + } EXACTTRIGGER_TOUCH(this, toucher); g = this.gravity; - if (!(this.spawnflags & 1)) - { - if(toucher.trigger_gravity_check) - { - if(this == toucher.trigger_gravity_check.enemy) - { + if (!(this.spawnflags & 1)) { + if (toucher.trigger_gravity_check) { + if (this == toucher.trigger_gravity_check.enemy) { // same? toucher.trigger_gravity_check.count = 2; // gravity one more frame... return; } // compare prio - if(this.cnt > toucher.trigger_gravity_check.enemy.cnt) + if (this.cnt > toucher.trigger_gravity_check.enemy.cnt) { trigger_gravity_remove(toucher); - else + } else { return; + } } toucher.trigger_gravity_check = spawn(); toucher.trigger_gravity_check.enemy = this; @@ -73,35 +69,38 @@ void trigger_gravity_touch(entity this, entity toucher) setthink(toucher.trigger_gravity_check, trigger_gravity_check_think); toucher.trigger_gravity_check.nextthink = time; toucher.trigger_gravity_check.count = 2; - if(toucher.gravity) + if (toucher.gravity) { g *= toucher.gravity; + } } - if (toucher.gravity != g) - { + if (toucher.gravity != g) { toucher.gravity = g; - if(this.noise != "") - _sound (toucher, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM); + if (this.noise != "") { + _sound(toucher, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM); + } UpdateCSQCProjectile(this.owner); } } spawnfunc(trigger_gravity) { - if(this.gravity == 1) + if (this.gravity == 1) { return; + } EXACTTRIGGER_INIT; settouch(this, trigger_gravity_touch); - if(this.noise != "") + if (this.noise != "") { precache_sound(this.noise); + } this.state = true; - IFTARGETED - { + if (THIS_TARGETED) { this.use = trigger_gravity_use; - if(this.spawnflags & 2) + if (this.spawnflags & 2) { this.state = false; + } } } #endif