]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/trigger/hurt.qc
take3: format 903 files
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / hurt.qc
index d0ba4ebd19b252e925e425bb6cd2089475cffeff..999280066edaae1b63f2bf5d51349bac342f212f 100644 (file)
@@ -2,52 +2,49 @@
 #ifdef SVQC
 void trigger_hurt_use(entity this, entity actor, entity trigger)
 {
-       if(IS_PLAYER(actor))
+       if (IS_PLAYER(actor)) {
                this.enemy = actor;
-       else
+       } else {
                this.enemy = NULL; // let's just destroy it, if taking over is too much work
+       }
 }
 
 .float triggerhurttime;
 void trigger_hurt_touch(entity this, entity toucher)
 {
-       if (this.active != ACTIVE_ACTIVE)
+       if (this.active != ACTIVE_ACTIVE) {
                return;
+       }
 
-       if(this.team)
-               if(((this.spawnflags & 4) == 0) == (this.team != toucher.team))
+       if (this.team) {
+               if (((this.spawnflags & 4) == 0) == (this.team != toucher.team)) {
                        return;
+               }
+       }
 
        // only do the EXACTTRIGGER_TOUCH checks when really needed (saves some cpu)
-       if (toucher.iscreature)
-       {
-               if (toucher.takedamage)
-               if (toucher.triggerhurttime < time)
-               {
-                       EXACTTRIGGER_TOUCH(this, toucher);
-                       toucher.triggerhurttime = time + 1;
+       if (toucher.iscreature) {
+               if (toucher.takedamage) {
+                       if (toucher.triggerhurttime < time) {
+                               EXACTTRIGGER_TOUCH(this, toucher);
+                               toucher.triggerhurttime = time + 1;
 
-                       entity own;
-                       own = this.enemy;
-                       if (!IS_PLAYER(own))
-                       {
-                               own = this;
-                               this.enemy = NULL; // I still hate you all
-                       }
+                               entity own;
+                               own = this.enemy;
+                               if (!IS_PLAYER(own)) {
+                                       own = this;
+                                       this.enemy = NULL; // I still hate you all
+                               }
 
-                       Damage (toucher, this, own, this.dmg, DEATH_HURTTRIGGER.m_id, toucher.origin, '0 0 0');
+                               Damage(toucher, this, own, this.dmg, DEATH_HURTTRIGGER.m_id, toucher.origin, '0 0 0');
+                       }
                }
-       }
-       else if(toucher.damagedbytriggers)
-       {
-               if(toucher.takedamage)
-               {
+       } else if (toucher.damagedbytriggers) {
+               if (toucher.takedamage) {
                        EXACTTRIGGER_TOUCH(this, toucher);
                        Damage(toucher, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, toucher.origin, '0 0 0');
                }
        }
-
-       return;
 }
 
 /*QUAKED spawnfunc_trigger_hurt (.5 .5 .5) ?
@@ -65,18 +62,23 @@ spawnfunc(trigger_hurt)
        settouch(this, trigger_hurt_touch);
        this.use = trigger_hurt_use;
        this.enemy = world; // I hate you all
-       if (!this.dmg)
+       if (!this.dmg) {
                this.dmg = 1000;
-       if (this.message == "")
+       }
+       if (this.message == "") {
                this.message = "was in the wrong place";
-       if (this.message2 == "")
+       }
+       if (this.message2 == "") {
                this.message2 = "was thrown into a world of hurt by";
+       }
        // this.message = "someone like %s always gets wrongplaced";
 
-       if(!trigger_hurt_first)
+       if (!trigger_hurt_first) {
                trigger_hurt_first = this;
-       if(trigger_hurt_last)
+       }
+       if (trigger_hurt_last) {
                trigger_hurt_last.trigger_hurt_next = this;
+       }
        trigger_hurt_last = this;
 }
 
@@ -84,9 +86,11 @@ float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end)
 {
        entity th;
 
-       for(th = trigger_hurt_first; th; th = th.trigger_hurt_next)
-               if(tracebox_hits_box(start, mi, ma, end, th.absmin, th.absmax))
+       for (th = trigger_hurt_first; th; th = th.trigger_hurt_next) {
+               if (tracebox_hits_box(start, mi, ma, end, th.absmin, th.absmax)) {
                        return true;
+               }
+       }
 
        return false;
 }