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