Xonotic
follow.qc
Go to the documentation of this file.
1 #include "follow.qh"
2 // the way this entity works makes it no use to CSQC, as it removes itself instantly
3 
4 #ifdef SVQC
5 void follow_init(entity this)
6 {
7  entity src, dst;
8  src = NULL;
9  dst = NULL;
10  if(this.killtarget != "")
11  src = find(NULL, targetname, this.killtarget);
12  if(this.target != "")
13  dst = find(NULL, targetname, this.target);
14 
15  if(!src && !dst)
16  {
17  objerror(this, "follow: could not find target/killtarget");
18  return;
19  }
20 
21  if(this.jointtype)
22  {
23  // already done :P entity must stay
24  this.aiment = src;
25  this.enemy = dst;
26  }
27  else if(!src || !dst)
28  {
29  objerror(this, "follow: could not find target/killtarget");
30  return;
31  }
32  else if(this.spawnflags & FOLLOW_ATTACH)
33  {
34  // attach
35  if(this.spawnflags & FOLLOW_LOCAL)
36  {
37  setattachment(dst, src, this.message);
38  }
39  else
40  {
41  attach_sameorigin(dst, src, this.message);
42  }
43 
44  dst.solid = SOLID_NOT; // solid doesn't work with attachment
45  delete(this);
46  }
47  else
48  {
49  if(this.spawnflags & FOLLOW_LOCAL)
50  {
52  dst.aiment = src;
53  // dst.punchangle = '0 0 0'; // keep unchanged
54  dst.view_ofs = dst.origin;
55  dst.v_angle = dst.angles;
56  }
57  else
58  {
59  follow_sameorigin(dst, src);
60  }
61 
62  delete(this);
63  }
64 }
65 
66 spawnfunc(misc_follow)
67 {
68  InitializeEntity(this, follow_init, INITPRIO_FINDTARGET);
69 }
70 #endif
const float SOLID_NOT
Definition: csprogsdefs.qc:244
string killtarget
Definition: subs.qh:48
const int FOLLOW_LOCAL
Definition: follow.qh:5
entity() spawn
spawnfunc(info_player_attacker)
Definition: sv_assault.qc:283
float spawnflags
Definition: progsdefs.qc:191
float jointtype
entity enemy
Definition: sv_ctf.qh:143
string message
Definition: powerups.qc:19
#define NULL
Definition: post.qh:17
const int FOLLOW_ATTACH
Definition: follow.qh:4
void InitializeEntity(entity e, void(entity this) func, int order)
Definition: world.qc:2146
float MOVETYPE_FOLLOW
string targetname
Definition: progsdefs.qc:194
entity aiment
Definition: movetypes.qh:90
string target
Definition: progsdefs.qc:193
void set_movetype(entity this, int mt)