]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_triggers.qc
Move most centerprints into the notifications system
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_triggers.qc
index 65846f5e38ba332e8f6e226c8f29831f18474260..725eb9b1ab5fc26b05baa4329696e20a2f693e3c 100644 (file)
@@ -61,14 +61,12 @@ void SUB_UseTargets()
 //
 // print the message
 //
-       if (IS_PLAYER(activator) && self.message != "")
+       if(IS_PLAYER(activator) && self.message != "")
+       if(IS_REAL_CLIENT(activator))
        {
-               if(IS_REAL_CLIENT(activator))
-               {
-                       centerprint (activator, self.message);
-                       if (self.noise == "")
-                               play2(activator, "misc/talk.wav");
-               }
+               Send_Notification(NOTIF_ONE, activator, MSG_CENTER, CENTER_TRIGGER, self.message);
+               if (self.noise == "")
+                       play2(activator, "misc/talk.wav");
        }
 
 //
@@ -137,8 +135,8 @@ void SUB_UseTargets()
 
 //=============================================================================
 
-float  SPAWNFLAG_NOMESSAGE = 1;
-float  SPAWNFLAG_NOTOUCH = 1;
+const float    SPAWNFLAG_NOMESSAGE = 1;
+const float    SPAWNFLAG_NOTOUCH = 1;
 
 // the wait time has passed, so set back up for another activation
 void multi_wait()
@@ -171,7 +169,7 @@ void multi_trigger()
        }
 
        if (self.noise)
-               sound (self.enemy, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NORM);
+               sound (self.enemy, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
 
 // don't trigger again until reset
        self.takedamage = DAMAGE_NO;
@@ -210,7 +208,7 @@ void multi_touch()
                        return;
 
        if(self.team)
-               if((self.spawnflags & 4 == 0) == (self.team != other.team))
+               if(((self.spawnflags & 4) == 0) == (self.team != other.team))
                        return;
 
 // if the trigger has an angles field, check player's facing direction
@@ -378,32 +376,26 @@ void spawnfunc_trigger_delay()
 
 void counter_use()
 {
-       self.count = self.count - 1;
+       self.count -= 1;
        if (self.count < 0)
                return;
 
-       if (self.count != 0)
+       if (self.count == 0)
        {
-               if (IS_PLAYER(activator)
-               && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
-               {
-                       if (self.count >= 4)
-                               centerprint (activator, "There are more to go...");
-                       else if (self.count == 3)
-                               centerprint (activator, "Only 3 more to go...");
-                       else if (self.count == 2)
-                               centerprint (activator, "Only 2 more to go...");
-                       else
-                               centerprint (activator, "Only 1 more to go...");
-               }
-               return;
+               if(IS_PLAYER(activator) && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
+                       Send_Notification(NOTIF_ONE, activator, MSG_CENTER, CENTER_SEQUENCE_COMPLETED);
+                       
+               self.enemy = activator;
+               multi_trigger ();
+       }
+       else
+       {
+               if(IS_PLAYER(activator) && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
+               if(self.count >= 4)
+                       Send_Notification(NOTIF_ONE, activator, MSG_CENTER, CENTER_SEQUENCE_COUNTER);
+               else
+                       Send_Notification(NOTIF_ONE, activator, MSG_CENTER, CENTER_SEQUENCE_COUNTER_FEWMORE, self.count);
        }
-
-       if (IS_PLAYER(activator)
-       && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
-               centerprint(activator, "Sequence completed!");
-       self.enemy = activator;
-       multi_trigger ();
 }
 
 void counter_reset()
@@ -445,7 +437,7 @@ void trigger_hurt_touch()
                return;
 
        if(self.team)
-               if((self.spawnflags & 4 == 0) == (self.team != other.team))
+               if(((self.spawnflags & 4) == 0) == (self.team != other.team))
                        return;
 
        // only do the EXACTTRIGGER_TOUCH checks when really needed (saves some cpu)
@@ -549,7 +541,7 @@ void trigger_heal_touch()
                        {
                                other.health = min(other.health + self.health, self.max_health);
                                other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
-                               sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NORM);
+                               sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
                        }
                }
        }
@@ -660,7 +652,7 @@ void trigger_gravity_touch()
        {
                other.gravity = g;
                if(self.noise != "")
-                       sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NORM);
+                       sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
                UpdateCSQCProjectile(self.owner);
        }
 }
@@ -775,9 +767,9 @@ void spawnfunc_target_speaker()
        if(!self.atten && !(self.spawnflags & 4))
        {
                IFTARGETED
-                       self.atten = ATTN_NORM;
+                       self.atten = ATTEN_NORM;
                else
-                       self.atten = ATTN_STATIC;
+                       self.atten = ATTEN_STATIC;
        }
        else if(self.atten < 0)
                self.atten = 0;
@@ -949,7 +941,7 @@ void spawnfunc_func_pointparticles()
                self.bgmscriptsustain = 0;
 
        if(!self.atten)
-               self.atten = ATTN_NORM;
+               self.atten = ATTEN_NORM;
        else if(self.atten < 0)
                self.atten = 0;
        if(!self.volume)
@@ -1214,7 +1206,7 @@ void misc_laser_think()
        if(self.dmg)
        {
                if(self.team)
-                       if((self.spawnflags & 8 == 0) == (self.team != hitent.team))
+                       if(((self.spawnflags & 8) == 0) == (self.team != hitent.team))
                                return;
                if(hitent.takedamage)
                        Damage(hitent, self, self, ((self.dmg < 0) ? 100000 : (self.dmg * frametime)), DEATH_HURTTRIGGER, hitloc, '0 0 0');
@@ -1400,7 +1392,7 @@ void trigger_impulse_touch1()
     if(!pushdeltatime) return;
 
     other.velocity = other.velocity + normalize(targ.origin - self.origin) * str * pushdeltatime;
-    other.flags &~= FL_ONGROUND;
+    other.flags &= ~FL_ONGROUND;
     UpdateCSQCProjectile(other);
 }