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