]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/misc/follow.qc
It actually compiles
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / misc / follow.qc
1 #ifdef SVQC
2 void follow_init()
3 {
4         entity src, dst;
5         src = world;
6         dst = world;
7         if(self.killtarget != "")
8                 src = find(world, targetname, self.killtarget);
9         if(self.target != "")
10                 dst = find(world, targetname, self.target);
11
12         if(!src && !dst)
13         {
14                 objerror("follow: could not find target/killtarget");
15                 return;
16         }
17
18         if(self.jointtype)
19         {
20                 // already done :P entity must stay
21                 self.aiment = src;
22                 self.enemy = dst;
23         }
24         else if(!src || !dst)
25         {
26                 objerror("follow: could not find target/killtarget");
27                 return;
28         }
29         else if(self.spawnflags & 1)
30         {
31                 // attach
32                 if(self.spawnflags & 2)
33                 {
34                         setattachment(dst, src, self.message);
35                 }
36                 else
37                 {
38                         attach_sameorigin(dst, src, self.message);
39                 }
40
41                 dst.solid = SOLID_NOT; // solid doesn't work with attachment
42                 remove(self);
43         }
44         else
45         {
46                 if(self.spawnflags & 2)
47                 {
48                         dst.movetype = MOVETYPE_FOLLOW;
49                         dst.aiment = src;
50                         // dst.punchangle = '0 0 0'; // keep unchanged
51                         dst.view_ofs = dst.origin;
52                         dst.v_angle = dst.angles;
53                 }
54                 else
55                 {
56                         follow_sameorigin(dst, src);
57                 }
58
59                 remove(self);
60         }
61 }
62
63 void spawnfunc_misc_follow()
64 {
65         InitializeEntity(self, follow_init, INITPRIO_FINDTARGET);
66 }
67 #endif