]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/t_teleporters.qc
Merge branch 'master' into Mario/classname_checks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_teleporters.qc
index 25dc837f953a514ce0ad9918b02d6d0bec92adc2..2932ad68b143bed0b8d8cf342717592bc48eaa49 100644 (file)
@@ -29,12 +29,12 @@ void trigger_teleport_use()
 
 float check_tdeath(entity player, vector org, vector telefragmin, vector telefragmax)
 {
-       if (player.classname == "player" && player.health >= 1)
+       if (IS_PLAYER(player) && player.health >= 1)
        {
                TDEATHLOOP(org)
                {
                        if not(teamplay && autocvar_g_telefrags_teamplay && head.team == player.team)
-                               if(head.classname == "player")
+                               if(IS_PLAYER(head))
                                        if(head.health >= 1)
                                                return 1;
                }
@@ -46,11 +46,11 @@ void tdeath(entity player, entity teleporter, entity telefragger, vector telefra
 {
        TDEATHLOOP(player.origin)
        {
-               if (player.classname == "player" && player.health >= 1)
+               if (IS_PLAYER(player) && player.health >= 1)
                {
                        if not(teamplay && autocvar_g_telefrags_teamplay && head.team == player.team)
                        {
-                               if(head.classname == "player")
+                               if(IS_PLAYER(head))
                                        if(head.health >= 1)
                                                ++tdeath_hit;
                                Damage (head, teleporter, telefragger, 10000, DEATH_TELEFRAG, head.origin, '0 0 0');
@@ -75,6 +75,11 @@ void spawn_tdeath(vector v0, entity e, vector v)
 #define TELEPORT_FLAGS_WARPZONE   0
 #define TELEPORT_FLAGS_PORTAL     (TELEPORT_FLAG_SOUND | TELEPORT_FLAG_PARTICLES | TELEPORT_FLAG_TDEATH | TELEPORT_FLAG_FORCE_TDEATH)
 #define TELEPORT_FLAGS_TELEPORTER (TELEPORT_FLAG_SOUND | TELEPORT_FLAG_PARTICLES | TELEPORT_FLAG_TDEATH)
+
+// types for .teleportable entity setting
+#define TELEPORT_NORMAL 1 // play sounds/effects etc
+#define TELEPORT_SIMPLE 2 // only do teleport, nothing special
+
 void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags)
 {
        entity telefragger;
@@ -87,7 +92,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle
 
        makevectors (to_angles);
 
-       if(player.classname == "player") // don't play sounds or show particles for anything that isn't a player, maybe change later to block only observers
+       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
                {
@@ -114,7 +119,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle
 
        UpdateCSQCProjectileAfterTeleport(player);
 
-       if(player.classname == "player")
+       if(IS_PLAYER(player))
        {
                if(tflags & TELEPORT_FLAG_TDEATH)
                        if(player.takedamage && player.deadflag == DEAD_NO && !g_race && !g_cts && (autocvar_g_telefrags || (tflags & TELEPORT_FLAG_FORCE_TDEATH)))
@@ -197,20 +202,17 @@ void Teleport_Touch (void)
        if (self.active != ACTIVE_ACTIVE)
                return;
        
-       if not(other.iscreature)
-               return;
-
-       // for gameplay: vehicles can't teleport
-       if (other.vehicle_flags & VHF_ISVEHICLE)
+       if not(other.teleportable)
                return;
     
-    if(other.vehicle)
-        return;
-        
-    if(other.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
-        return;
+       if(other.vehicle)
+       if(!other.vehicle.teleportable)
+               return;
+                       
+       if(other.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
+               return;
         
-       if (other.deadflag != DEAD_NO)
+       if(other.deadflag != DEAD_NO)
                return;
 
        if(self.team)
@@ -219,7 +221,7 @@ void Teleport_Touch (void)
 
        EXACTTRIGGER_TOUCH;
 
-       if(other.classname == "player")
+       if(IS_PLAYER(other))
                RemoveGrapplingHook(other);
                
        entity e;
@@ -323,7 +325,7 @@ void spawnfunc_trigger_teleport (void)
        // this must be called to spawn the teleport waypoints for bots
        InitializeEntity(self, teleport_findtarget, INITPRIO_FINDTARGET);
 
-       if (!self.target)
+       if (self.target == "")
        {
                objerror ("Teleporter with no target");
                return;
@@ -344,7 +346,7 @@ void WarpZone_PostTeleportPlayer_Callback(entity pl)
                        print("A non-projectile got through a warpzone and its owner cleared. It's a ", pl.classname, ".\n");
                pl.owner = world;
        }
-       if(pl.classname == "player")
+       if(IS_PLAYER(pl))
        {
                // reset tracking of oldvelocity for impact damage (sudden velocity changes)
                pl.oldvelocity = pl.velocity;