1 void Damage (entity targ, entity inflictor, entity attacker, float
2 damage, float deathtype, vector hitloc, vector force);
6 if (other == self.owner)
8 // so teleporting shots etc can't telefrag
9 if (!self.owner.takedamage)
11 if (!other.takedamage)
14 if ((self.owner.classname == "player") && (self.owner.health >= 1))
15 Damage (other, self, self.owner, 10000, DEATH_TELEFRAG, other.origin, '0 0 0');
16 else if (other.health < 1) // corpses gib
17 Damage (other, self, self.owner, 10000, DEATH_TELEFRAG, other.origin, '0 0 0');
18 else // dead bodies and monsters gib themselves instead of telefragging
19 Damage (self.owner, self, self.owner, 10000, DEATH_TELEFRAG, self.owner.origin, '0 0 0');
26 self.owner.effects = self.owner.effects - (self.owner.effects & EF_NODRAW);
27 if (self.owner.weaponentity)
28 self.owner.weaponentity.flags = self.owner.weaponentity.flags - (self.owner.weaponentity.flags & FL_FLY);
33 // org2 is where they will return to if the teleport fails
34 void(vector org, entity death_owner, vector org2) spawn_tdeath =
39 // death.classname = "teledeath";
40 death.movetype = MOVETYPE_NONE;
41 death.solid = SOLID_TRIGGER;
42 death.angles = '0 0 0';
44 setsize (death, death_owner.mins - '1 1 1', death_owner.maxs + '1 1 1');
45 setorigin (death, org);
46 death.touch = tdeath_touch;
47 death.nextthink = time + 0.2;
48 death.think = tdeath_remove;
49 death.owner = death_owner;
51 // hide entity to avoid "ghosts" between teleporter and destination caused by clientside interpolation
52 death.owner.effects = death.owner.effects | EF_NODRAW;
53 if (death.owner.weaponentity) // misuse FL_FLY to avoid EF_NODRAW on viewmodel
54 death.owner.weaponentity.flags = death.owner.weaponentity.flags | FL_FLY;
56 force_retouch = 2; // make sure even still objects get hit
59 void Teleport_Touch (void)
63 if (!other.flags & FL_CLIENT) // FIXME: Make missiles firable through the teleport too
66 // Make teleport effect where the player left
67 sound (other, CHAN_ITEM, "misc/teleport.ogg", 1, ATTN_NORM);
68 te_teleport (other.origin);
70 dest = find (world, targetname, self.target);
72 objerror ("Teleporter with nonexistant target");
74 // Make teleport effect where the player arrived
75 sound (other, CHAN_ITEM, "misc/teleport.ogg", 1, ATTN_NORM);
76 makevectors (dest.mangle);
77 te_teleport (dest.origin + v_forward * 32);
79 spawn_tdeath(dest.origin, other, other.origin);
81 // Relocate the player
82 //setorigin (other, dest.origin);
83 setorigin (other, dest.origin + '0 0 1' * (1 - other.mins_z - 24));
84 other.angles = dest.mangle;
85 other.fixangle = TRUE;
87 // keep velocity but change movement direction
88 other.velocity = v_forward * vlen(other.velocity);
90 other.flags = other.flags - (other.flags & FL_ONGROUND);
91 // reset tracking of oldvelocity for impact damage (sudden velocity changes)
92 other.oldvelocity = other.velocity;
93 // reset tracking of who pushed you into a hazard (for kill credit)
97 void info_teleport_destination (void)
99 self.mangle = self.angles;
100 self.angles = '0 0 0';
102 //setorigin (self, self.origin + '0 0 27'); // To fix a mappers' habit as old as Quake
103 setorigin (self, self.origin);
105 if (!self.targetname)
106 objerror ("Teleport destination without a targetname");
109 void misc_teleporter_dest (void)
111 info_teleport_destination();
114 void trigger_teleport (void)
116 self.angles = '0 0 0';
118 self.solid = SOLID_TRIGGER;
119 self.movetype = MOVETYPE_NONE;
121 setmodel (self, self.model);
126 self.touch = Teleport_Touch;
129 objerror ("Teleporter with no target");