]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/client/projectile.qc
add the missing files
[divverent/nexuiz.git] / data / qcsrc / client / projectile.qc
1 .float itime;
2 .float count; // set if clientside projectile
3 .float cnt; // sound index
4 .float gravity;
5
6 void Projectile_Draw()
7 {
8         float dt;
9         vector oldorg, org;
10
11         oldorg = self.origin;
12
13         if(self.count & 0x80)
14         {
15                 dt = time - self.itime;
16                 self.velocity_z -= dt * self.gravity * getstatf(242); // STAT_MOVEVARS_GRAVITY
17                 org = self.origin + dt * self.velocity;
18                 self.itime = time;
19                 tracebox(self.origin, self.mins, self.maxs, org, MOVE_NORMAL, self);
20                 self.origin = trace_endpos;
21                 self.angles = vectoangles(self.velocity);
22         }
23         else
24         {
25                 InterpolateOrigin_Do();
26         }
27
28         switch(self.cnt)
29         {
30                 default:
31                 case 0:
32                         break;
33                 case 1:
34                         break; // electro uses no trail
35                 case 2:
36                         trailparticles(self, particleeffectnum("TR_ROCKET"), oldorg, self.origin); // rocket
37                         break;
38                 case 3:
39                         trailparticles(self, particleeffectnum("TR_VORESPIKE"), oldorg, self.origin); // seeker
40                         break;
41         }
42
43         self.renderflags = 0;
44
45         if(self.count & 0x80 || self.iflags & IFLAG_VALID)
46                 R_AddEntity(self);
47 }
48
49 void Ent_RemoveProjectile()
50 {
51         if(self.cnt)
52                 sound(self, CHAN_PAIN, "misc/null.wav", VOL_BASE, ATTN_NORM);
53 }
54
55 void Ent_Projectile()
56 {
57         float f;
58         float sz;
59
60         InterpolateOrigin_Undo();
61
62         // projectile properties:
63         //   kind (interpolated, or clientside)
64         //
65         //   modelindex
66         //   origin
67         //   scale
68         //   if clientside:
69         //     velocity
70         //     gravity
71         //   soundindex (hardcoded list)
72         //   effects
73         //
74         // projectiles don't send angles, because they always follow the velocity
75         
76         f = ReadByte();
77         self.count = (f & 0xC0);
78         self.iflags = IFLAG_AUTOANGLES | IFLAG_ANGLES;
79
80         if(self.count & 0x80)
81                 InterpolateOrigin_Undo();
82
83         if(f & 1)
84         {
85                 self.origin_x = ReadCoord();
86                 self.origin_y = ReadCoord();
87                 self.origin_z = ReadCoord();
88                 if(self.count & 0x80)
89                 {
90                         self.itime = time;
91                         self.velocity_x = ReadCoord();
92                         self.velocity_y = ReadCoord();
93                         self.velocity_z = ReadCoord();
94                         self.gravity = ReadCoord();
95                 }
96         }
97
98         if(f & 2)
99         {
100                 self.modelindex = ReadShort();
101                 if(f & 0x40)
102                 {
103                         self.scale = ReadByte() / 16.0;
104                         self.effects = ReadShort();
105                         self.effects |= 65536 * ReadByte();
106                 }
107                 else
108                 {
109                         self.scale = 1;
110                         self.effects = 0;
111                 }
112
113                 self.cnt = ReadShort();
114                 switch(self.cnt)
115                 {
116                         case 1:
117                                 sound(self, CHAN_PAIN, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
118                                 break;
119                         case 2:
120                                 sound(self, CHAN_PAIN, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
121                                 break;
122                         case 3:
123                                 sound(self, CHAN_PAIN, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
124                                 break;
125                         default:
126                                 break;
127                 }
128
129                 sz = ReadByte();
130                 switch(sz)
131                 {
132                         case 0:
133                         default:
134                                 self.mins = self.maxs = '0 0 0';
135                                 break;
136                 }
137         }
138
139         if(self.count)
140                 InterpolateOrigin_Note();
141         
142         self.draw = Projectile_Draw;
143 }