3 if (other == self.owner)
5 // so teleporting shots etc can't telefrag
6 if (!self.owner.takedamage)
11 if ((self.owner.classname == "player") && (self.owner.health >= 1))
12 Damage (other, self, self.owner, 10000, DEATH_TELEFRAG, other.origin, '0 0 0');
13 else if (other.health < 1) // corpses gib
14 Damage (other, self, self.owner, 10000, DEATH_TELEFRAG, other.origin, '0 0 0');
15 else // dead bodies and monsters gib themselves instead of telefragging
16 Damage (self.owner, self, self.owner, 10000, DEATH_TELEFRAG, self.owner.origin, '0 0 0');
23 self.owner.effects = self.owner.effects - (self.owner.effects & EF_NODRAW);
24 if (self.owner.weaponentity)
25 self.owner.weaponentity.flags = self.owner.weaponentity.flags - (self.owner.weaponentity.flags & FL_FLY);
30 // org2 is where they will return to if the teleport fails
31 void(vector org, entity death_owner, vector org2) spawn_tdeath =
36 // death.classname = "teledeath";
37 death.movetype = MOVETYPE_NONE;
38 death.solid = SOLID_TRIGGER;
39 death.angles = '0 0 0';
41 setsize (death, death_owner.mins - '1 1 1', death_owner.maxs + '1 1 1');
42 setorigin (death, org);
43 death.touch = tdeath_touch;
44 death.nextthink = time + 0.2;
45 death.think = tdeath_remove;
46 death.owner = death_owner;
48 // hide entity to avoid "ghosts" between teleporter and destination caused by clientside interpolation
49 death.owner.effects = death.owner.effects | EF_NODRAW;
50 if (death.owner.weaponentity) // misuse FL_FLY to avoid EF_NODRAW on viewmodel
51 death.owner.weaponentity.flags = death.owner.weaponentity.flags | FL_FLY;
53 force_retouch = 2; // make sure even still objects get hit
56 void Teleport_Touch (void)
62 if (!other.flags & FL_CLIENT) // FIXME: Make missiles firable through the teleport too
65 // Make teleport effect where the player left
66 sound (other, CHAN_ITEM, "misc/teleport.wav", 1, ATTN_NORM);
67 pointparticles(particleeffectnum("teleport"), other.origin, '0 0 0', 1);
69 // Make teleport effect where the player arrived
70 sound (other, CHAN_ITEM, "misc/teleport.wav", 1, ATTN_NORM);
71 makevectors (self.enemy.mangle);
72 pointparticles(particleeffectnum("teleport"), self.enemy.origin + v_forward * 32, '0 0 0', 1);
74 // Relocate the player
75 setorigin (other, self.enemy.origin + '0 0 1' * (1 - other.mins_z - 24));
76 other.angles = self.enemy.mangle;
77 other.fixangle = TRUE;
78 other.velocity = v_forward * vlen(other.velocity);
80 // Kill anyone else in the teleporter box (NO MORE TDEATH)
86 deathmin = other.absmin;
87 deathmax = other.absmax;
88 deathradius = max(vlen(deathmin), vlen(deathmax));
89 for(head = findradius(other.origin, deathradius); head; head = head.chain)
92 if(boxesoverlap(deathmin, deathmax, head.absmin, head.absmax))
94 if ((other.classname == "player") && (other.health >= 1))
95 Damage (head, self, other, 10000, DEATH_TELEFRAG, head.origin, '0 0 0');
96 else if (other.health < 1) // corpses gib
97 Damage (head, self, other, 10000, DEATH_TELEFRAG, head.origin, '0 0 0');
98 else // dead bodies and monsters gib themselves instead of telefragging
99 Damage (other, self, other, 10000, DEATH_TELEFRAG, other.origin, '0 0 0');
104 other.effects = other.effects | EF_NODRAW;
105 if (other.weaponentity) // misuse FL_FLY to avoid EF_NODRAW on viewmodel
106 other.weaponentity.flags = other.weaponentity.flags | FL_FLY;
107 other.teleport_time = time + cvar("sys_ticrate");
109 other.flags = other.flags - (other.flags & FL_ONGROUND);
110 // reset tracking of oldvelocity for impact damage (sudden velocity changes)
111 other.oldvelocity = other.velocity;
112 // reset tracking of who pushed you into a hazard (for kill credit)
115 // stop player name display
120 ClearSelectedPlayer();
125 void info_teleport_destination (void)
127 self.mangle = self.angles;
128 self.angles = '0 0 0';
130 //setorigin (self, self.origin + '0 0 27'); // To fix a mappers' habit as old as Quake
131 setorigin (self, self.origin);
133 if (!self.targetname)
134 objerror ("Teleport destination without a targetname");
137 void misc_teleporter_dest (void)
139 info_teleport_destination();
142 void target_teleporter (void)
144 info_teleport_destination();
147 void teleport_findtarget (void)
150 self.touch = Teleport_Touch;
152 self.enemy = find (world, targetname, self.target);
155 objerror ("Teleporter with nonexistant target");
160 self.dest = self.enemy.origin;
161 waypoint_spawnforteleporter(self, self.dest, 0);
164 void trigger_teleport (void)
166 self.angles = '0 0 0';
168 self.solid = SOLID_TRIGGER;
169 self.movetype = MOVETYPE_NONE;
171 setmodel (self, self.model); // no precision needed
176 self.think = teleport_findtarget;
177 self.nextthink = time + 0.2;
180 objerror ("Teleporter with no target");