]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/teleporters.qc
rain/snow added, not tested
[divverent/nexuiz.git] / qcsrc / teleporters.qc
1
2 void Teleport_Touch (void)
3 {
4         if (other.health < 1)
5                 return;
6         if (other.classname != "player")        // FIXME: Make missiles firable through the teleport too
7                 return;
8
9         // Make teleport effect where the player left
10         sound (other, CHAN_ITEM, "misc/Teleport.wav", 1, ATTN_NORM);
11         te_teleport (other.origin);
12         
13         dest = find (world, targetname, self.target);
14         if (!dest)
15                 objerror ("Teleporter with nonexistant target");
16
17         // Make teleport effect where the player arrived
18         sound (other, CHAN_ITEM, "misc/Teleport.wav", 1, ATTN_NORM);
19         makevectors (dest.mangle);
20         te_teleport (dest.origin + v_forward * 32);
21
22         // Relocate the player
23         setorigin (other, dest.origin);
24         other.angles = dest.mangle;
25         other.fixangle = TRUE;
26         
27         other.velocity = '0 0 0';
28         
29         other.flags = other.flags - (other.flags & FL_ONGROUND);
30 }
31
32 void info_teleport_destination (void)
33 {
34         self.mangle = self.angles;
35         self.angles = '0 0 0';
36
37         setorigin (self, self.origin + '0 0 27');       // To fix a mappers' habit as old as Quake
38
39         if (!self.targetname)
40                 objerror ("Teleport destination without a targetname");
41 }
42
43 void trigger_teleport (void)
44 {
45         self.angles = '0 0 0';
46
47         self.solid = SOLID_TRIGGER;
48         self.movetype = MOVETYPE_NONE;
49         
50         setmodel (self, self.model);
51         
52         self.model = "";
53         self.modelindex = 0;
54         
55         self.touch = Teleport_Touch;
56         
57         if (!self.target)
58                 objerror ("Teleporter with no target");
59 }