Merge branch 'master' into Mario/vaporizer_damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / teleport.qc
1 #ifdef SVQC
2 void trigger_teleport_use()
3 {
4         if(teamplay)
5                 self.team = activator.team;
6 #ifdef SVQC
7         self.SendFlags |= SF_TRIGGER_UPDATE;
8 #endif
9 }
10
11 void Teleport_Touch (void)
12 {
13         entity oldself;
14         string s;
15
16         if (self.active != ACTIVE_ACTIVE)
17                 return;
18
19         if (!other.teleportable)
20                 return;
21
22         if(other.vehicle)
23         if(!other.vehicle.teleportable)
24                 return;
25
26         if(IS_TURRET(other))
27                 return;
28
29         if(other.deadflag != DEAD_NO)
30                 return;
31
32         if(self.team)
33                 if(((self.spawnflags & 4) == 0) == (self.team != other.team))
34                         return;
35
36         EXACTTRIGGER_TOUCH;
37
38         if(IS_PLAYER(other))
39                 RemoveGrapplingHook(other);
40
41         entity e;
42         e = Simple_TeleportPlayer(self, other);
43
44         activator = other;
45         s = self.target; self.target = string_null;
46         SUB_UseTargets();
47         if (!self.target) self.target = s;
48
49         oldself = self;
50         self = e;
51         SUB_UseTargets();
52         self = oldself;
53 }
54
55 void spawnfunc_trigger_teleport()
56 {
57         self.angles = '0 0 0';
58
59         EXACTTRIGGER_INIT;
60
61         self.active = ACTIVE_ACTIVE;
62
63         self.use = trigger_teleport_use;
64
65         // this must be called to spawn the teleport waypoints for bots
66         InitializeEntity(self, teleport_findtarget, INITPRIO_FINDTARGET);
67
68         if (self.target == "")
69         {
70                 objerror ("Teleporter with no target");
71                 return;
72         }
73
74         self.teleport_next = teleport_first;
75         teleport_first = self;
76 }
77 #endif