]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/misc/follow.qc
spawnfunc and SendEntity3 have a 'this' parameter, use it
[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(entity this)
5 {
6         entity src, dst;
7         src = world;
8         dst = world;
9         if(this.killtarget != "")
10                 src = find(world, targetname, this.killtarget);
11         if(this.target != "")
12                 dst = find(world, targetname, this.target);
13
14         if(!src && !dst)
15         {
16                 objerror("follow: could not find target/killtarget");
17                 return;
18         }
19
20         if(this.jointtype)
21         {
22                 // already done :P entity must stay
23                 this.aiment = src;
24                 this.enemy = dst;
25         }
26         else if(!src || !dst)
27         {
28                 objerror("follow: could not find target/killtarget");
29                 return;
30         }
31         else if(this.spawnflags & 1)
32         {
33                 // attach
34                 if(this.spawnflags & 2)
35                 {
36                         setattachment(dst, src, this.message);
37                 }
38                 else
39                 {
40                         attach_sameorigin(dst, src, this.message);
41                 }
42
43                 dst.solid = SOLID_NOT; // solid doesn't work with attachment
44                 remove(this);
45         }
46         else
47         {
48                 if(this.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(this);
62         }
63 }
64
65 spawnfunc(misc_follow)
66 {
67         InitializeEntity(this, follow_init, INITPRIO_FINDTARGET);
68 }
69 #endif