421c0e73f62daa67a65cef9f14d98fe191eeaefe
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics / movetypes / follow.qc
1 void _Movetype_Physics_Follow(entity this) // SV_Physics_Follow
2 {
3         entity e = this.aiment;
4
5         if(e.angles == this.punchangle)
6         {
7                 this.move_origin = e.origin + this.view_ofs;
8         }
9         else
10         {
11                 vector ang, v;
12                 ang_x = -this.punchangle_x;
13                 ang_y = this.punchangle_y;
14                 ang_z = this.punchangle_z;
15                 makevectors(ang);
16                 v_x = this.view_ofs_x * v_forward_x + this.view_ofs_y * v_right_x + this.view_ofs_z * v_up_x;
17                 v_y = this.view_ofs_x * v_forward_y + this.view_ofs_y * v_right_y + this.view_ofs_z * v_up_y;
18                 v_z = this.view_ofs_x * v_forward_z + this.view_ofs_y * v_right_z + this.view_ofs_z * v_up_z;
19                 ang = e.angles;
20                 ang_x = -e.angles_x;
21                 makevectors(ang);
22                 this.move_origin_x = v_x * v_forward_x + v_y * v_forward_y + v_z * v_forward_z + e.origin_x;
23                 this.move_origin_x = v_x * v_right_x + v_y * v_right_y + v_z * v_right_z + e.origin_y;
24                 this.move_origin_x = v_x * v_up_x + v_y * v_up_y + v_z * v_up_z + e.origin_z;
25         }
26
27         this.move_angles = e.angles + this.v_angle;
28         _Movetype_LinkEdict(this, false);
29 }