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_BULLET_GLOWING_TRACER: setmodel(self, "models/tracer.mdl"); break;
297 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl"); break;
298 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl"); break;
299 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl"); break;
300 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3"); break;
301 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3"); break;
302 case PROJECTILE_LASER: setmodel(self, "models/laser.mdl"); break;
303 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3"); break;
304 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3"); self.scale = 4; break;
305 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3"); self.scale = 4; break;
306 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3"); break;
307 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; break;
308 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; break;
309 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; break; // particle effect is good enough
310 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; break; // particle effect is good enough
312 error("Received invalid CSQC projectile, can't work with this!");
318 self.colormod = '0 0 0';
319 self.move_touch = SUB_Stop;
320 self.move_movetype = MOVETYPE_TOSS;
324 case PROJECTILE_ELECTRO:
325 // only new engines support sound moving with object
326 loopsound(self, CHAN_PROJECTILE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
327 self.mins = '0 0 -3';
328 self.maxs = '0 0 -3';
329 self.move_movetype = MOVETYPE_BOUNCE;
330 self.move_touch = SUB_Null;
332 case PROJECTILE_ROCKET:
333 loopsound(self, CHAN_PROJECTILE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
334 self.mins = '-3 -3 -3';
337 case PROJECTILE_GRENADE:
338 self.mins = '0 0 -3';
339 self.maxs = '0 0 -3';
341 case PROJECTILE_GRENADE_BOUNCING:
342 self.mins = '0 0 -3';
343 self.maxs = '0 0 -3';
344 self.move_movetype = MOVETYPE_BOUNCE;
345 self.move_touch = SUB_Null;
347 case PROJECTILE_PORTO_RED:
348 self.colormod = '2 1 1';
350 self.move_movetype = MOVETYPE_BOUNCE;
351 self.move_touch = SUB_Null;
353 case PROJECTILE_PORTO_BLUE:
354 self.colormod = '1 1 2';
356 self.move_movetype = MOVETYPE_BOUNCE;
357 self.move_touch = SUB_Null;
359 case PROJECTILE_HAGAR_BOUNCING:
360 self.move_movetype = MOVETYPE_BOUNCE;
361 self.move_touch = SUB_Null;
363 case PROJECTILE_CRYLINK_BOUNCING:
364 self.move_movetype = MOVETYPE_BOUNCE;
365 self.move_touch = SUB_Null;
367 case PROJECTILE_FIREBALL:
368 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
369 self.mins = '-16 -16 -16';
370 self.maxs = '16 16 16';
372 case PROJECTILE_FIREMINE:
373 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
374 self.move_movetype = MOVETYPE_BOUNCE;
375 self.move_touch = SUB_Null;
376 self.mins = '-4 -4 -4';
386 if(self.move_movetype == MOVETYPE_FLY)
387 self.move_movetype = MOVETYPE_TOSS;
388 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
389 self.move_movetype = MOVETYPE_BOUNCE;
393 if(self.move_movetype == MOVETYPE_TOSS)
394 self.move_movetype = MOVETYPE_FLY;
395 if(self.move_movetype == MOVETYPE_BOUNCE)
396 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
399 if(!(self.count & 0x80))
400 InterpolateOrigin_Note();
402 self.draw = Projectile_Draw;
403 self.entremove = Ent_RemoveProjectile;
406 void Projectile_Precache()
408 precache_model("models/ebomb.mdl");
409 precache_model("models/elaser.mdl");
410 precache_model("models/grenademodel.md3");
411 precache_model("models/hagarmissile.mdl");
412 precache_model("models/hlac_bullet.md3");
413 precache_model("models/laser.mdl");
414 precache_model("models/plasmatrail.mdl");
415 precache_model("models/rocket.md3");
416 precache_model("models/tracer.mdl");
417 precache_sound("weapons/electro_fly.wav");
418 precache_sound("weapons/rocket_fly.wav");
419 precache_sound("weapons/fireball_fly.wav");
420 precache_sound("weapons/fireball_fly2.wav");