1 .vector iorigin1, iorigin2;
3 .vector trail_oldorigin;
5 .float fade_time, fade_rate;
13 self.move_velocity = self.move_avelocity = '0 0 0';
14 self.move_movetype = MOVETYPE_NONE;
18 .float count; // set if clientside projectile
19 .float cnt; // sound index
24 void Projectile_ResetTrail(vector to)
26 self.trail_oldorigin = to;
27 self.trail_oldtime = time;
30 void Projectile_DrawTrail(vector to)
35 from = self.trail_oldorigin;
36 t0 = self.trail_oldtime;
37 self.trail_oldorigin = to;
38 self.trail_oldtime = time;
40 // force the effect even for stationary firemine
41 if(self.cnt == PROJECTILE_FIREMINE)
47 particles_alphamin = particles_alphamax = sqrt(self.alpha);
48 boxparticles(self.traileffect, self, from, to, self.velocity, self.velocity, sqrt(self.alpha), PARTICLES_USEALPHA);
52 void Projectile_Draw()
65 //self.move_flags &~= FL_ONGROUND;
66 if(self.move_movetype == MOVETYPE_NONE || self.move_movetype == MOVETYPE_FLY)
67 Movetype_Physics_NoMatchServer();
68 // the trivial movetypes do not have to match the
69 // server's ticrate as they are ticrate independent
70 // NOTE: this assumption is only true if MOVETYPE_FLY
71 // projectiles detonate on impact. If they continue
72 // moving, we might still be ticrate dependent.
74 Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
75 if(!(self.move_flags & FL_ONGROUND))
76 if(self.velocity != '0 0 0')
77 self.move_angles = self.angles = vectoangles(self.velocity);
81 InterpolateOrigin_Do();
86 drawn = (time >= self.spawntime - 0.02);
87 t = max(time, self.spawntime);
91 drawn = (self.iflags & IFLAG_VALID);
95 if(!(f & FL_ONGROUND))
101 case PROJECTILE_GRENADE:
102 rot = '-2000 0 0'; // forward
105 case PROJECTILE_GRENADE_BOUNCING:
106 rot = '0 -1000 0'; // sideways
108 case PROJECTILE_HOOKBOMB:
109 rot = '1000 0 0'; // forward
114 self.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(self.angles), rot * (t - self.spawntime)));
122 a = 1 - (time - self.fade_time) * self.fade_rate;
123 self.alpha = bound(0, self.alphamod * a, 1);
126 self.renderflags = 0;
128 trailorigin = self.origin;
131 case PROJECTILE_GRENADE:
132 case PROJECTILE_GRENADE_BOUNCING:
133 trailorigin += v_right * 1 + v_forward * -10;
139 Projectile_DrawTrail(trailorigin);
141 Projectile_ResetTrail(trailorigin);
150 case PROJECTILE_BULLET_GLOWING:
151 case PROJECTILE_BULLET_GLOWING_TRACER:
152 adddynamiclight(self.origin, 50 * a, '1 1 0');
158 self.drawmask = MASK_NORMAL;
161 void loopsound(entity e, float ch, string samp, float vol, float attn)
166 sound(e, ch, samp, vol, attn);
170 void Ent_RemoveProjectile()
173 sound(self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTN_NORM);
175 if(self.count & 0x80)
177 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
178 Projectile_DrawTrail(trace_endpos);
182 void Ent_Projectile()
186 // projectile properties:
187 // kind (interpolated, or clientside)
195 // soundindex (hardcoded list)
198 // projectiles don't send angles, because they always follow the velocity
201 self.count = (f & 0x80);
202 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES;
203 self.solid = SOLID_TRIGGER;
204 //self.effects = EF_NOMODELFLAGS;
206 // this should make collisions with bmodels more exact, but it leads to
207 // projectiles no longer being able to lie on a bmodel
208 self.move_nomonsters = MOVE_WORLDONLY;
210 self.move_flags |= FL_ONGROUND;
212 self.move_flags &~= FL_ONGROUND;
216 // for some unknown reason, we don't need to care for
217 // sv_gameplayfix_delayprojectiles here.
218 self.move_time = time;
219 self.spawntime = time;
222 self.move_time = max(self.move_time, time);
224 if(!(self.count & 0x80))
225 InterpolateOrigin_Undo();
229 self.origin_x = ReadCoord();
230 self.origin_y = ReadCoord();
231 self.origin_z = ReadCoord();
232 if(self.count & 0x80)
234 self.velocity_x = ReadCoord();
235 self.velocity_y = ReadCoord();
236 self.velocity_z = ReadCoord();
238 self.gravity = ReadCoord();
240 self.gravity = 0; // none
241 self.move_origin = self.origin;
242 self.move_velocity = self.velocity;
245 if(time == self.spawntime || (self.count & 0x80) || (f & 0x08))
247 self.trail_oldorigin = self.origin;
248 if(!(self.count & 0x80))
249 InterpolateOrigin_Reset();
254 self.fade_time = time + ReadByte() * ticrate;
255 self.fade_rate = 1 / (ReadByte() * ticrate);
266 self.cnt = ReadByte();
268 self.silent = (self.cnt & 0x80);
269 self.cnt = (self.cnt & 0x7F);
272 self.traileffect = 0;
275 case PROJECTILE_ELECTRO: setmodel(self, "models/ebomb.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
276 case PROJECTILE_ROCKET: setmodel(self, "models/rocket.md3");self.traileffect = particleeffectnum("TR_ROCKET"); self.scale = 2; break;
277 case PROJECTILE_BULLET: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_bullet"); break;
278 case PROJECTILE_BULLET_GLOWING: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle_weak"); break;
279 case PROJECTILE_BULLET_GLOWING_TRACER: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle"); break;
280 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
281 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
282 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
283 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
284 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
285 case PROJECTILE_MINE: setmodel(self, "models/mine.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
286 case PROJECTILE_LASER: setmodel(self, "models/laser.mdl");self.traileffect = particleeffectnum(""); break;
287 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3");self.traileffect = particleeffectnum(""); break;
288 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
289 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
290 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_KNIGHTSPIKE"); break;
291 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("tr_hagar"); self.scale = 0.75; break;
292 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("tr_hagar"); self.scale = 0.75; break;
293 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("fireball"); break; // particle effect is good enough
294 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("firemine"); break; // particle effect is good enough
295 case PROJECTILE_TAG: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum("TR_ROCKET"); break;
296 case PROJECTILE_FLAC: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; self.traileffect = particleeffectnum("TR_SEEKER"); break;
297 case PROJECTILE_SEEKER: setmodel(self, "models/tagrocket.md3"); self.traileffect = particleeffectnum("TR_SEEKER"); break;
299 case PROJECTILE_RAPTORBOMB: setmodel(self, "models/vehicles/clusterbomb.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
300 case PROJECTILE_RAPTORBOMBLET: setmodel(self, "models/vehicles/bomblet.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
301 case PROJECTILE_RAPTORCANNON: setmodel(self, "models/plasmatrail.mdl"); self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
303 case PROJECTILE_SPIDERROCKET: setmodel(self, "models/vehicles/rocket02.md3"); self.traileffect = particleeffectnum("spiderbot_rocket_thrust"); break;
304 case PROJECTILE_WAKIROCKET: setmodel(self, "models/vehicles/rocket01.md3"); self.traileffect = particleeffectnum("wakizashi_rocket_thrust"); break;
305 case PROJECTILE_WAKICANNON: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum(""); break;
307 case PROJECTILE_BUMBLE_GUN: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
308 case PROJECTILE_BUMBLE_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
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;
324 case PROJECTILE_ELECTRO:
325 // only new engines support sound moving with object
326 loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
327 self.mins = '0 0 -4';
328 self.maxs = '0 0 -4';
329 self.move_movetype = MOVETYPE_BOUNCE;
330 self.move_touch = SUB_Null;
331 self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
332 self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
334 case PROJECTILE_ROCKET:
335 loopsound(self, CH_SHOTS_SINGLE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
336 self.mins = '-3 -3 -3';
339 case PROJECTILE_GRENADE:
340 self.mins = '-3 -3 -3';
343 case PROJECTILE_GRENADE_BOUNCING:
344 self.mins = '-3 -3 -3';
346 self.move_movetype = MOVETYPE_BOUNCE;
347 self.move_touch = SUB_Null;
348 self.move_bounce_factor = g_balance_grenadelauncher_bouncefactor;
349 self.move_bounce_stopspeed = g_balance_grenadelauncher_bouncestop;
351 case PROJECTILE_MINE:
352 self.mins = '-4 -4 -4';
355 case PROJECTILE_PORTO_RED:
356 self.colormod = '2 1 1';
358 self.move_movetype = MOVETYPE_BOUNCE;
359 self.move_touch = SUB_Null;
361 case PROJECTILE_PORTO_BLUE:
362 self.colormod = '1 1 2';
364 self.move_movetype = MOVETYPE_BOUNCE;
365 self.move_touch = SUB_Null;
367 case PROJECTILE_HAGAR_BOUNCING:
368 self.move_movetype = MOVETYPE_BOUNCE;
369 self.move_touch = SUB_Null;
371 case PROJECTILE_CRYLINK_BOUNCING:
372 self.move_movetype = MOVETYPE_BOUNCE;
373 self.move_touch = SUB_Null;
375 case PROJECTILE_FIREBALL:
376 loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
377 self.mins = '-16 -16 -16';
378 self.maxs = '16 16 16';
380 case PROJECTILE_FIREMINE:
381 loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
382 self.move_movetype = MOVETYPE_BOUNCE;
383 self.move_touch = SUB_Null;
384 self.mins = '-4 -4 -4';
388 self.mins = '-2 -2 -2';
391 case PROJECTILE_FLAC:
392 self.mins = '-2 -2 -2';
395 case PROJECTILE_SEEKER:
396 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
397 self.mins = '-4 -4 -4';
400 case PROJECTILE_RAPTORBOMB:
401 self.mins = '-3 -3 -3';
404 case PROJECTILE_RAPTORBOMBLET:
406 case PROJECTILE_RAPTORCANNON:
408 case PROJECTILE_SPIDERROCKET:
409 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
411 case PROJECTILE_WAKIROCKET:
412 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
415 case PROJECTILE_WAKICANNON:
417 case PROJECTILE_BUMBLE_GUN:
418 // only new engines support sound moving with object
419 loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
420 self.mins = '0 0 -4';
421 self.maxs = '0 0 -4';
422 self.move_movetype = MOVETYPE_BOUNCE;
423 self.move_touch = SUB_Null;
424 self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
425 self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
435 if(self.move_movetype == MOVETYPE_FLY)
436 self.move_movetype = MOVETYPE_TOSS;
437 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
438 self.move_movetype = MOVETYPE_BOUNCE;
442 if(self.move_movetype == MOVETYPE_TOSS)
443 self.move_movetype = MOVETYPE_FLY;
444 if(self.move_movetype == MOVETYPE_BOUNCE)
445 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
448 if(!(self.count & 0x80))
449 InterpolateOrigin_Note();
451 self.draw = Projectile_Draw;
452 self.entremove = Ent_RemoveProjectile;
455 void Projectile_Precache()
457 precache_model("models/ebomb.mdl");
458 precache_model("models/elaser.mdl");
459 precache_model("models/grenademodel.md3");
460 precache_model("models/mine.md3");
461 precache_model("models/hagarmissile.mdl");
462 precache_model("models/hlac_bullet.md3");
463 precache_model("models/laser.mdl");
464 precache_model("models/plasmatrail.mdl");
465 precache_model("models/rocket.md3");
466 precache_model("models/tagrocket.md3");
467 precache_model("models/tracer.mdl");
469 precache_sound("weapons/electro_fly.wav");
470 precache_sound("weapons/rocket_fly.wav");
471 precache_sound("weapons/fireball_fly.wav");
472 precache_sound("weapons/fireball_fly2.wav");
473 precache_sound("weapons/tag_rocket_fly.wav");