]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/teleporters.qc
Merge branch 'master' into terencehill/hud_fixes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / teleporters.qc
index d646a631c928d4f99550e5d9347d428fc286caf9..afeabfcddc3cba2cf3da9d779b5007a79176505c 100644 (file)
@@ -68,7 +68,7 @@ void spawn_tdeath(vector v0, entity e, vector v)
 #endif
 
 void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags)
-{SELFPARAM();
+{
        entity telefragger;
        vector from;
 
@@ -80,12 +80,25 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle
        makevectors (to_angles);
 
 #ifdef SVQC
+    SELFPARAM();
        if(player.teleportable == TELEPORT_NORMAL) // don't play sounds or show particles for anything that isn't a player, maybe change later to block only observers
        {
                if(self.pushltime < time) // only show one teleport effect per teleporter per 0.2 seconds, for better fps
                {
                        if(tflags & TELEPORT_FLAG_SOUND)
-                               _sound (player, CH_TRIGGER, ((teleporter.noise != "") ? teleporter.noise : SND(TELEPORT)), VOL_BASE, ATTEN_NORM);
+                       {
+                               string thesound = SND(TELEPORT);
+                               if(teleporter.noise != "")
+                               {
+                                       RandomSelection_Init();
+                                       FOREACH_WORD(teleporter.noise, true,
+                                       {
+                                               RandomSelection_Add(NULL, 0, it, 1, 1);
+                                       });
+                                       thesound = RandomSelection_chosen_string;
+                               }
+                               _sound (player, CH_TRIGGER, thesound, VOL_BASE, ATTEN_NORM);
+                       }
                        if(tflags & TELEPORT_FLAG_PARTICLES)
                        {
                                Send_Effect(EFFECT_TELEPORT, player.origin, '0 0 0', 1);
@@ -148,7 +161,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle
                {
                        player.pusher = teleporter.owner;
                        player.pushltime = time + autocvar_g_maxpushtime;
-                       player.istypefrag = player.BUTTON_CHAT;
+                       player.istypefrag = PHYS_INPUT_BUTTON_CHAT(player);
                }
                else
                {
@@ -203,21 +216,21 @@ entity Simple_TeleportPlayer(entity teleporter, entity player)
 
 #ifdef SVQC
        if(e.speed)
-               if(vlen(player.velocity) > e.speed)
+               if(vdist(player.velocity, >, e.speed))
                        player.velocity = normalize(player.velocity) * max(0, e.speed);
 #elif defined(CSQC)
        if(e.speed)
-               if(vlen(player.move_velocity) > e.speed)
+               if(vdist(player.move_velocity, >, e.speed))
                        player.move_velocity = normalize(player.move_velocity) * max(0, e.speed);
 #endif
 
 #ifdef SVQC
        if(STAT(TELEPORT_MAXSPEED, player))
-               if(vlen(player.velocity) > STAT(TELEPORT_MAXSPEED, player))
+               if(vdist(player.velocity, >, STAT(TELEPORT_MAXSPEED, player)))
                        player.velocity = normalize(player.velocity) * max(0, STAT(TELEPORT_MAXSPEED, player));
 #elif defined(CSQC)
        if(STAT(TELEPORT_MAXSPEED, player))
-               if(vlen(player.move_velocity) > STAT(TELEPORT_MAXSPEED, player))
+               if(vdist(player.move_velocity, >, STAT(TELEPORT_MAXSPEED, player)))
                        player.move_velocity = normalize(player.move_velocity) * max(0, STAT(TELEPORT_MAXSPEED, player));
 #endif
 
@@ -236,6 +249,7 @@ entity Simple_TeleportPlayer(entity teleporter, entity player)
 
 void teleport_findtarget()
 {
+    SELFPARAM();
        int n = 0;
        entity e;
        for(e = world; (e = find(e, targetname, self.target)); )
@@ -286,15 +300,13 @@ entity Teleport_Find(vector mi, vector ma)
 }
 
 void WarpZone_PostTeleportPlayer_Callback(entity pl)
-{SELFPARAM();
+{
 #ifdef SVQC
        makevectors(pl.angles);
        Reset_ArcBeam(pl, v_forward);
        UpdateCSQCProjectileAfterTeleport(pl);
        UpdateItemAfterTeleport(pl);
-       {
-               WITH(entity, self, pl, anticheat_fixangle());
-       }
+    if (IS_PLAYER(pl)) anticheat_fixangle(pl);
 #endif
        // "disown" projectiles after teleport
        if(pl.owner)