float check_tdeath(entity player, vector org, vector telefragmin, vector telefragmax)
{
- TDEATHLOOP(org)
+ if (player.classname == "player" && player.health >= 1)
{
- if ((player.classname == "player") && (player.health >= 1))
+ TDEATHLOOP(org)
{
- if(head.classname == "player")
- if(head.health >= 1)
- return 1;
+ if not(teams_matter && autocvar_g_telefrags_teamplay && head.team == player.team)
+ if(head.classname == "player")
+ if(head.health >= 1)
+ return 1;
}
}
return 0;
{
TDEATHLOOP(player.origin)
{
- if ((player.classname == "player") && (player.health >= 1))
+ if (player.classname == "player" && player.health >= 1)
{
- if(head.classname == "player")
- if(head.health >= 1)
- ++tdeath_hit;
- Damage (head, teleporter, telefragger, 10000, DEATH_TELEFRAG, head.origin, '0 0 0');
+ if not(teams_matter && autocvar_g_telefrags_teamplay && head.team == player.team)
+ {
+ if(head.classname == "player")
+ if(head.health >= 1)
+ ++tdeath_hit;
+ Damage (head, teleporter, telefragger, 10000, DEATH_TELEFRAG, head.origin, '0 0 0');
+ }
}
- else if (telefragger.health < 1) // corpses gib
- Damage (head, teleporter, telefragger, 10000, DEATH_TELEFRAG, head.origin, '0 0 0');
else // dead bodies and monsters gib themselves instead of telefragging
Damage (telefragger, teleporter, telefragger, 10000, DEATH_TELEFRAG, telefragger.origin, '0 0 0');
}
#define TELEPORT_FLAG_SOUND 1
#define TELEPORT_FLAG_PARTICLES 2
#define TELEPORT_FLAG_TDEATH 4
+#define TELEPORT_FLAG_FORCE_TDEATH 8
#define TELEPORT_FLAGS_WARPZONE 0
-#define TELEPORT_FLAGS_PORTAL (TELEPORT_FLAG_SOUND | TELEPORT_FLAG_PARTICLES)
+#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)
void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags)
{
makevectors (to_angles);
- if(self.pushltime < time) // only show one teleport effect per teleporter per 0.2 seconds, for better fps
+ 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(tflags & TELEPORT_FLAG_SOUND)
- sound (player, CHAN_TRIGGER, "misc/teleport.wav", VOL_BASE, ATTN_NORM);
- if(tflags & TELEPORT_FLAG_PARTICLES)
+ if(self.pushltime < time) // only show one teleport effect per teleporter per 0.2 seconds, for better fps
{
- pointparticles(particleeffectnum("teleport"), player.origin, '0 0 0', 1);
- pointparticles(particleeffectnum("teleport"), to + v_forward * 32, '0 0 0', 1);
+ if(tflags & TELEPORT_FLAG_SOUND)
+ sound (player, CHAN_TRIGGER, "misc/teleport.wav", VOL_BASE, ATTN_NORM);
+ if(tflags & TELEPORT_FLAG_PARTICLES)
+ {
+ pointparticles(particleeffectnum("teleport"), player.origin, '0 0 0', 1);
+ pointparticles(particleeffectnum("teleport"), to + v_forward * 32, '0 0 0', 1);
+ }
+ self.pushltime = time + 0.2;
}
- self.pushltime = time + 0.2;
}
// Relocate the player
if(player.classname == "player")
{
if(tflags & TELEPORT_FLAG_TDEATH)
- if(player.takedamage && player.deadflag == DEAD_NO && !g_race && !g_cts && cvar("g_telefrags"))
+ if(player.takedamage && player.deadflag == DEAD_NO && !g_race && !g_cts && (autocvar_g_telefrags || (tflags & TELEPORT_FLAG_FORCE_TDEATH)))
tdeath(player, teleporter, telefragger, telefragmin, telefragmax);
// player no longer is on ground
if(teleporter.owner)
{
player.pusher = teleporter.owner;
- player.pushltime = time + cvar("g_maxpushtime");
+ player.pushltime = time + autocvar_g_maxpushtime;
}
else
{
player.pushltime = 0;
}
- if(player.isbot)
- player.lastteleporttime = time;
+ player.lastteleporttime = time;
// stop player name display
{
}
}
-void Teleport_Touch (void)
+void Simple_TeleportPlayer(entity teleporter, entity player)
{
- entity oldself, e;
- vector o;
+ vector locout;
+ entity e;
float p;
-
- if (other.health < 1)
- return;
- if not(other.flags & FL_CLIENT) // FIXME: Make missiles firable through the teleport too
- return;
-
- if(self.team)
- if((self.spawnflags & 4 == 0) == (self.team != other.team))
- return;
-
- EXACTTRIGGER_TOUCH;
-
- makevectors(self.enemy.mangle);
-
- if(other.classname == "player")
- RemoveGrapplingHook(other);
- if(self.enemy)
- {
- e = self.enemy;
- }
- else
- {
+ // Find the output teleporter
+ if(!teleporter.enemy)
+ {
RandomSelection_Init();
- for(e = world; (e = find(e, targetname, self.target)); )
+ for(e = world; (e = find(e, targetname, teleporter.target)); )
{
p = 1;
- if(cvar("g_telefrags_avoid"))
+ if(autocvar_g_telefrags_avoid)
{
- o = e.origin + '0 0 1' * (1 - other.mins_z - 24);
- if(check_tdeath(other, o, '0 0 0', '0 0 0'))
+ locout = e.origin + '0 0 1' * (1 - player.mins_z - 24);
+ if(check_tdeath(player, locout, '0 0 0', '0 0 0'))
p = 0;
}
- if(e.cnt)
- RandomSelection_Add(e, 0, string_null, e.cnt, p);
- else
- RandomSelection_Add(e, 0, string_null, 1, p);
+ RandomSelection_Add(e, 0, string_null, (e.cnt ? e.cnt : 1), p);
}
- e = RandomSelection_chosen_ent;
+ teleporter.enemy = RandomSelection_chosen_ent;
}
- if(!e)
- {
- sprint(other, "Teleport destination vanished. Sorry... please complain to the mapper.\n");
- }
+ if(!teleporter.enemy) { sprint(player, "Teleport destination vanished. Sorry... please complain to the mapper.\n"); }
+
+ makevectors(teleporter.enemy.mangle);
+
+ if(teleporter.enemy.speed)
+ if(vlen(player.velocity) > teleporter.enemy.speed)
+ player.velocity = normalize(player.velocity) * max(0, teleporter.enemy.speed);
+
+ if(autocvar_g_teleport_maxspeed)
+ if(vlen(player.velocity) > autocvar_g_teleport_maxspeed)
+ player.velocity = normalize(player.velocity) * max(0, autocvar_g_teleport_maxspeed);
+
+ locout = teleporter.enemy.origin + '0 0 1' * (1 - player.mins_z - 24);
+ TeleportPlayer(teleporter, player, locout, teleporter.enemy.mangle, v_forward * vlen(player.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
+}
- if(e.speed)
- if(vlen(other.velocity) > e.speed)
- other.velocity = normalize(other.velocity) * max(0, e.speed);
- if(cvar("g_teleport_maxspeed"))
- if(vlen(other.velocity) > cvar("g_teleport_maxspeed"))
- other.velocity = normalize(other.velocity) * max(0, cvar("g_teleport_maxspeed"));
+void Teleport_Touch (void)
+{
+ entity oldself;
+ string s;
- o = e.origin + '0 0 1' * (1 - other.mins_z - 24);
- TeleportPlayer(self, other, o, e.mangle, v_forward * vlen(other.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
+ if (self.active != ACTIVE_ACTIVE)
+ return;
+
+ if (other.deadflag != DEAD_NO)
+ return;
+ if not(other.flags & FL_CLIENT) // FIXME: Make missiles firable through the teleport too
+ return;
- if(e.target)
- {
- oldself = self;
- activator = other;
- self = e;
- SUB_UseTargets();
- self = oldself;
- }
+ if(self.team)
+ if((self.spawnflags & 4 == 0) == (self.team != other.team))
+ return;
+
+ EXACTTRIGGER_TOUCH;
+
+ if(other.classname == "player")
+ RemoveGrapplingHook(other);
+
+ Simple_TeleportPlayer(self, other);
+
+ activator = other;
+ s = self.target; self.target = string_null;
+ SUB_UseTargets();
+ if not(self.target) self.target = s;
+
+ oldself = self;
+ self = self.enemy;
+ SUB_UseTargets();
+ self = oldself;
}
void spawnfunc_info_teleport_destination (void)
self.touch = Teleport_Touch;
}
+entity Teleport_Find(vector mi, vector ma)
+{
+ entity e;
+ for(e = world; (e = find(e, classname, "trigger_teleport")); )
+ if(WarpZoneLib_BoxTouchesBrush(mi, ma, e, world))
+ return e;
+ return world;
+}
+
+entity teleport_first;
+.entity teleport_next;
void spawnfunc_trigger_teleport (void)
{
self.angles = '0 0 0';
EXACTTRIGGER_INIT;
-
+
+ self.active = ACTIVE_ACTIVE;
+
self.use = trigger_teleport_use;
// this must be called to spawn the teleport waypoints for bots
objerror ("Teleporter with no target");
return;
}
+
+ self.teleport_next = teleport_first;
+ teleport_first = self;
}
void WarpZone_PostTeleportPlayer_Callback(entity pl)
{
// reset tracking of oldvelocity for impact damage (sudden velocity changes)
pl.oldvelocity = pl.velocity;
+ // reset teleport time tracking too (or multijump can cause insane speeds)
+ pl.lastteleporttime = time;
}
}