2 .vector trail_oldorigin;
11 self.move_velocity = self.move_avelocity = '0 0 0';
12 self.move_movetype = MOVETYPE_NONE;
15 .float count; // set if clientside projectile
16 .float cnt; // sound index
21 void Projectile_DrawTrail(vector to)
25 from = self.trail_oldorigin;
26 t0 = self.trail_oldtime;
27 self.trail_oldorigin = to;
28 self.trail_oldtime = time;
34 case PROJECTILE_FIREMINE:
37 case PROJECTILE_ELECTRO:
38 trailparticles(self, particleeffectnum("TR_NEXUIZPLASMA"), from, to);
47 case PROJECTILE_ROCKET:
48 trailparticles(self, particleeffectnum("TR_ROCKET"), from, to);
50 case PROJECTILE_CRYLINK:
51 trailparticles(self, particleeffectnum("TR_CRYLINKPLASMA"), from, to);
53 case PROJECTILE_CRYLINK_BOUNCING:
54 trailparticles(self, particleeffectnum("TR_CRYLINKPLASMA"), from, to);
56 case PROJECTILE_ELECTRO:
57 trailparticles(self, particleeffectnum("TR_NEXUIZPLASMA"), from, to);
59 case PROJECTILE_ELECTRO_BEAM:
60 trailparticles(self, particleeffectnum("TR_NEXUIZPLASMA"), from, to);
62 case PROJECTILE_GRENADE:
63 trailparticles(self, particleeffectnum("TR_KNIGHTSPIKE"), from, to);
65 case PROJECTILE_GRENADE_BOUNCING:
66 trailparticles(self, particleeffectnum("TR_KNIGHTSPIKE"), from, to);
68 case PROJECTILE_PORTO_RED:
69 trailparticles(self, particleeffectnum("TR_WIZSPIKE"), from, to);
71 case PROJECTILE_PORTO_BLUE:
72 trailparticles(self, particleeffectnum("TR_WIZSPIKE"), from, to);
74 case PROJECTILE_HOOKBOMB:
75 trailparticles(self, particleeffectnum("TR_KNIGHTSPIKE"), from, to);
77 case PROJECTILE_HAGAR:
78 trailparticles(self, particleeffectnum("TR_GRENADE"), from, to);
80 case PROJECTILE_HAGAR_BOUNCING:
81 trailparticles(self, particleeffectnum("TR_GRENADE"), from, to);
83 case PROJECTILE_BULLET:
84 trailparticles(self, particleeffectnum("tr_bullet"), from, to);
86 case PROJECTILE_BULLET_GLOWING:
87 trailparticles(self, particleeffectnum("tr_bullet"), from, to);
89 case PROJECTILE_BULLET_GLOWING_TRACER:
90 trailparticles(self, particleeffectnum("tr_rifle"), from, to);
92 case PROJECTILE_FIREMINE:
93 trailparticles(self, particleeffectnum("firemine"), from, to);
95 case PROJECTILE_FIREBALL:
96 trailparticles(self, particleeffectnum("fireball"), from, to);
103 void Projectile_Draw()
113 if(self.count & 0x80)
115 //self.move_flags &~= FL_ONGROUND;
116 Movetype_Physics_MatchServer();
117 if(!(self.move_flags & FL_ONGROUND))
118 self.angles = vectoangles(self.velocity);
122 InterpolateOrigin_Do();
125 if(self.count & 0x80)
127 drawn = (time >= self.spawntime - 0.02);
128 t = max(time, self.spawntime);
132 drawn = (self.iflags & IFLAG_VALID);
136 if(!(f & FL_ONGROUND))
142 case PROJECTILE_GRENADE:
143 rot = '-2000 0 0'; // forward
146 case PROJECTILE_GRENADE_BOUNCING:
147 rot = '0 -1000 0'; // sideways
149 case PROJECTILE_HOOKBOMB:
150 rot = '1000 0 0'; // forward
155 self.angles = AnglesTransform_Multiply(self.angles, rot * (t - self.spawntime));
158 fixedmakevectors(self.angles);
160 trailorigin = self.origin;
163 case PROJECTILE_GRENADE:
164 case PROJECTILE_GRENADE_BOUNCING:
165 trailorigin += v_right * 1 + v_forward * -10;
171 Projectile_DrawTrail(trailorigin);
174 self.trail_oldorigin = trailorigin;
175 self.trail_oldtime = time;
183 case PROJECTILE_BULLET_GLOWING:
184 case PROJECTILE_BULLET_GLOWING_TRACER:
185 R_AddDynamicLight(self.origin, 50, '1 1 0');
191 self.renderflags = 0;
196 void loopsound(entity e, float ch, string samp, float vol, float attn)
201 sound(e, ch, samp, vol, attn);
205 void Ent_RemoveProjectile()
208 sound(self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
210 if(self.count & 0x80)
212 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
213 Projectile_DrawTrail(trace_endpos);
217 void Ent_Projectile()
221 // projectile properties:
222 // kind (interpolated, or clientside)
230 // soundindex (hardcoded list)
233 // projectiles don't send angles, because they always follow the velocity
236 self.count = (f & 0x80);
237 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES;
238 self.solid = SOLID_TRIGGER;
239 //self.effects = EF_NOMODELFLAGS;
241 // this should make collisions with bmodels more exact, but it leads to
242 // projectiles no longer being able to lie on a bmodel
243 self.move_nomonsters = MOVE_WORLDONLY;
245 self.move_flags |= FL_ONGROUND;
247 self.move_flags &~= FL_ONGROUND;
251 // for some unknown reason, we don't need to care for
252 // sv_gameplayfix_delayprojectiles here.
253 self.move_time = time;
254 self.spawntime = time;
257 self.move_time = max(self.move_time, time);
259 if(!(self.count & 0x80))
260 InterpolateOrigin_Undo();
264 self.origin_x = ReadCoord();
265 self.origin_y = ReadCoord();
266 self.origin_z = ReadCoord();
267 if(self.count & 0x80)
269 self.velocity_x = ReadCoord();
270 self.velocity_y = ReadCoord();
271 self.velocity_z = ReadCoord();
272 self.gravity = ReadCoord();
274 self.move_origin = self.origin;
275 self.move_velocity = self.velocity;
278 if(time == self.spawntime || (self.count & 0x80) || (f & 0x20))
279 self.trail_oldorigin = self.origin;
284 self.cnt = ReadByte();
286 self.silent = (self.cnt & 0x80);
287 self.cnt = (self.cnt & 0x7F);
292 case PROJECTILE_ELECTRO: setmodel(self, "models/ebomb.mdl"); break;
293 case PROJECTILE_ROCKET: setmodel(self, "models/rocket.md3"); self.scale = 2; break;
294 case PROJECTILE_BULLET: setmodel(self, "models/tracer.mdl"); break;
295 case PROJECTILE_BULLET_GLOWING: setmodel(self, "models/tracer.mdl"); break;
296 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl"); break;
297 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl"); break;
298 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl"); break;
299 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3"); break;
300 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3"); break;
301 case PROJECTILE_LASER: setmodel(self, "models/laser.mdl"); break;
302 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3"); break;
303 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3"); self.scale = 4; break;
304 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3"); self.scale = 4; break;
305 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3"); break;
306 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; break;
307 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; break;
308 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; break; // particle effect is good enough
309 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; break; // particle effect is good enough
311 error("Received invalid CSQC projectile, can't work with this!");
317 self.colormod = '0 0 0';
318 self.move_touch = SUB_Stop;
319 self.move_movetype = MOVETYPE_TOSS;
323 case PROJECTILE_ELECTRO:
324 // only new engines support sound moving with object
325 loopsound(self, CHAN_PROJECTILE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
326 self.mins = '0 0 -3';
327 self.maxs = '0 0 -3';
328 self.move_movetype = MOVETYPE_BOUNCE;
329 self.move_touch = SUB_Null;
331 case PROJECTILE_ROCKET:
332 loopsound(self, CHAN_PROJECTILE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
333 self.mins = '-3 -3 -3';
336 case PROJECTILE_GRENADE:
337 self.mins = '0 0 -3';
338 self.maxs = '0 0 -3';
340 case PROJECTILE_GRENADE_BOUNCING:
341 self.mins = '0 0 -3';
342 self.maxs = '0 0 -3';
343 self.move_movetype = MOVETYPE_BOUNCE;
344 self.move_touch = SUB_Null;
346 case PROJECTILE_PORTO_RED:
347 self.colormod = '2 1 1';
349 self.move_movetype = MOVETYPE_BOUNCE;
350 self.move_touch = SUB_Null;
352 case PROJECTILE_PORTO_BLUE:
353 self.colormod = '1 1 2';
355 self.move_movetype = MOVETYPE_BOUNCE;
356 self.move_touch = SUB_Null;
358 case PROJECTILE_HAGAR_BOUNCING:
359 self.move_movetype = MOVETYPE_BOUNCE;
360 self.move_touch = SUB_Null;
362 case PROJECTILE_CRYLINK_BOUNCING:
363 self.move_movetype = MOVETYPE_BOUNCE;
364 self.move_touch = SUB_Null;
366 case PROJECTILE_FIREBALL:
367 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
368 self.mins = '-16 -16 -16';
369 self.maxs = '16 16 16';
371 case PROJECTILE_FIREMINE:
372 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
373 self.move_movetype = MOVETYPE_BOUNCE;
374 self.move_touch = SUB_Null;
375 self.mins = '-4 -4 -4';
385 if(self.move_movetype == MOVETYPE_FLY)
386 self.move_movetype = MOVETYPE_TOSS;
387 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
388 self.move_movetype = MOVETYPE_BOUNCE;
392 if(self.move_movetype == MOVETYPE_TOSS)
393 self.move_movetype = MOVETYPE_FLY;
394 if(self.move_movetype == MOVETYPE_BOUNCE)
395 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
398 if(!(self.count & 0x80))
399 InterpolateOrigin_Note();
401 self.draw = Projectile_Draw;
402 self.entremove = Ent_RemoveProjectile;
405 void Projectile_Precache()
407 precache_model("models/ebomb.mdl");
408 precache_model("models/elaser.mdl");
409 precache_model("models/grenademodel.md3");
410 precache_model("models/hagarmissile.mdl");
411 precache_model("models/hlac_bullet.md3");
412 precache_model("models/laser.mdl");
413 precache_model("models/plasmatrail.mdl");
414 precache_model("models/rocket.md3");
415 precache_model("models/tracer.mdl");
416 precache_sound("weapons/electro_fly.wav");
417 precache_sound("weapons/rocket_fly.wav");
418 precache_sound("weapons/fireball_fly.wav");
419 precache_sound("weapons/fireball_fly2.wav");