1 .vector iorigin1, iorigin2;
3 .vector trail_oldorigin;
5 .float fade_time, fade_rate;
9 self.move_velocity = self.move_avelocity = '0 0 0';
10 self.move_movetype = MOVETYPE_NONE;
14 .float count; // set if clientside projectile
15 .float cnt; // sound index
20 void Projectile_ResetTrail(vector to)
22 self.trail_oldorigin = to;
23 self.trail_oldtime = time;
26 void Projectile_DrawTrail(vector to)
31 from = self.trail_oldorigin;
32 t0 = self.trail_oldtime;
33 self.trail_oldorigin = to;
34 self.trail_oldtime = time;
36 // force the effect even for stationary firemine
37 if(self.cnt == PROJECTILE_FIREMINE)
43 particles_alphamin = particles_alphamax = particles_fade = sqrt(self.alpha);
44 boxparticles(self.traileffect, self, from, to, self.velocity, self.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
48 void Projectile_Draw()
61 //self.move_flags &= ~FL_ONGROUND;
62 if(self.move_movetype == MOVETYPE_NONE || self.move_movetype == MOVETYPE_FLY)
63 Movetype_Physics_NoMatchServer();
64 // the trivial movetypes do not have to match the
65 // server's ticrate as they are ticrate independent
66 // NOTE: this assumption is only true if MOVETYPE_FLY
67 // projectiles detonate on impact. If they continue
68 // moving, we might still be ticrate dependent.
70 Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
71 if(!(self.move_flags & FL_ONGROUND))
72 if(self.velocity != '0 0 0')
73 self.move_angles = self.angles = vectoangles(self.velocity);
77 InterpolateOrigin_Do();
82 drawn = (time >= self.spawntime - 0.02);
83 t = max(time, self.spawntime);
87 drawn = (self.iflags & IFLAG_VALID);
91 if(!(f & FL_ONGROUND))
97 case PROJECTILE_GRENADE:
98 rot = '-2000 0 0'; // forward
101 case PROJECTILE_GRENADE_BOUNCING:
102 rot = '0 -1000 0'; // sideways
104 case PROJECTILE_NADE_RED_BURN:
105 case PROJECTILE_NADE_RED:
106 case PROJECTILE_NADE_BLUE_BURN:
107 case PROJECTILE_NADE_BLUE:
108 case PROJECTILE_NADE_YELLOW_BURN:
109 case PROJECTILE_NADE_YELLOW:
110 case PROJECTILE_NADE_PINK_BURN:
111 case PROJECTILE_NADE_PINK:
112 case PROJECTILE_NADE_BURN:
113 case PROJECTILE_NADE:
114 rot = self.avelocity;
116 case PROJECTILE_HOOKBOMB:
117 rot = '1000 0 0'; // forward
122 self.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(self.angles), rot * (t - self.spawntime)));
130 a = 1 - (time - self.fade_time) * self.fade_rate;
131 self.alpha = bound(0, self.alphamod * a, 1);
134 self.renderflags = 0;
136 trailorigin = self.origin;
139 case PROJECTILE_NADE_RED_BURN:
140 case PROJECTILE_NADE_RED:
141 case PROJECTILE_NADE_BLUE_BURN:
142 case PROJECTILE_NADE_BLUE:
143 case PROJECTILE_NADE_YELLOW_BURN:
144 case PROJECTILE_NADE_YELLOW:
145 case PROJECTILE_NADE_PINK_BURN:
146 case PROJECTILE_NADE_PINK:
147 case PROJECTILE_NADE_BURN:
148 case PROJECTILE_NADE:
149 trailorigin += v_up * 4;
151 case PROJECTILE_GRENADE:
152 case PROJECTILE_GRENADE_BOUNCING:
153 trailorigin += v_right * 1 + v_forward * -10;
159 Projectile_DrawTrail(trailorigin);
161 Projectile_ResetTrail(trailorigin);
170 // Possibly add dlights here.
175 self.drawmask = MASK_NORMAL;
178 void loopsound(entity e, float ch, string samp, float vol, float attn)
183 sound(e, ch, samp, vol, attn);
187 void Ent_RemoveProjectile()
189 if(self.count & 0x80)
191 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
192 Projectile_DrawTrail(trace_endpos);
196 void Ent_Projectile()
200 // projectile properties:
201 // kind (interpolated, or clientside)
209 // soundindex (hardcoded list)
212 // projectiles don't send angles, because they always follow the velocity
215 self.count = (f & 0x80);
216 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES | IFLAG_ORIGIN;
217 self.solid = SOLID_TRIGGER;
218 //self.effects = EF_NOMODELFLAGS;
220 // this should make collisions with bmodels more exact, but it leads to
221 // projectiles no longer being able to lie on a bmodel
222 self.move_nomonsters = MOVE_WORLDONLY;
224 self.move_flags |= FL_ONGROUND;
226 self.move_flags &= ~FL_ONGROUND;
230 // for some unknown reason, we don't need to care for
231 // sv_gameplayfix_delayprojectiles here.
232 self.move_time = time;
233 self.spawntime = time;
236 self.move_time = max(self.move_time, time);
238 if(!(self.count & 0x80))
239 InterpolateOrigin_Undo();
243 self.origin_x = ReadCoord();
244 self.origin_y = ReadCoord();
245 self.origin_z = ReadCoord();
246 setorigin(self, self.origin);
247 if(self.count & 0x80)
249 self.velocity_x = ReadCoord();
250 self.velocity_y = ReadCoord();
251 self.velocity_z = ReadCoord();
253 self.gravity = ReadCoord();
255 self.gravity = 0; // none
256 self.move_origin = self.origin;
257 self.move_velocity = self.velocity;
260 if(time == self.spawntime || (self.count & 0x80) || (f & 0x08))
262 self.trail_oldorigin = self.origin;
263 if(!(self.count & 0x80))
264 InterpolateOrigin_Reset();
269 self.fade_time = time + ReadByte() * ticrate;
270 self.fade_rate = 1 / (ReadByte() * ticrate);
281 self.cnt = ReadByte();
283 self.silent = (self.cnt & 0x80);
284 self.cnt = (self.cnt & 0x7F);
287 self.traileffect = 0;
290 case PROJECTILE_ELECTRO: setmodel(self, "models/ebomb.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
291 case PROJECTILE_ROCKET: setmodel(self, "models/rocket.md3");self.traileffect = particleeffectnum("TR_ROCKET"); self.scale = 2; break;
292 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
293 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
294 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
295 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
296 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
297 case PROJECTILE_MINE: setmodel(self, "models/mine.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
298 case PROJECTILE_BLASTER: setmodel(self, "models/laser.mdl");self.traileffect = particleeffectnum(""); break;
299 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3");self.traileffect = particleeffectnum(""); break;
300 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
301 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
302 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_KNIGHTSPIKE"); break;
303 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("tr_hagar"); self.scale = 0.75; break;
304 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("tr_hagar"); self.scale = 0.75; break;
305 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("fireball"); break; // particle effect is good enough
306 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("firemine"); break; // particle effect is good enough
307 case PROJECTILE_TAG: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum("TR_ROCKET"); break;
308 case PROJECTILE_FLAC: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; self.traileffect = particleeffectnum("TR_SEEKER"); break;
309 case PROJECTILE_SEEKER: setmodel(self, "models/tagrocket.md3"); self.traileffect = particleeffectnum("TR_SEEKER"); break;
311 case PROJECTILE_MAGE_SPIKE: setmodel(self, "models/ebomb.mdl"); self.traileffect = particleeffectnum("TR_VORESPIKE"); break;
312 case PROJECTILE_SHAMBLER_LIGHTNING: setmodel(self, "models/ebomb.mdl"); self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
314 case PROJECTILE_RAPTORBOMB: setmodel(self, "models/vehicles/clusterbomb.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
315 case PROJECTILE_RAPTORBOMBLET: setmodel(self, "models/vehicles/bomblet.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
316 case PROJECTILE_RAPTORCANNON: setmodel(self, "models/plasmatrail.mdl"); self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
318 case PROJECTILE_SPIDERROCKET: setmodel(self, "models/vehicles/rocket02.md3"); self.traileffect = particleeffectnum("spiderbot_rocket_thrust"); break;
319 case PROJECTILE_WAKIROCKET: setmodel(self, "models/vehicles/rocket01.md3"); self.traileffect = particleeffectnum("wakizashi_rocket_thrust"); break;
320 case PROJECTILE_WAKICANNON: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum(""); break;
322 case PROJECTILE_BUMBLE_GUN: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
323 case PROJECTILE_BUMBLE_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
325 case PROJECTILE_NADE_RED: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_red"); break;
326 case PROJECTILE_NADE_RED_BURN: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_red_burn"); break;
327 case PROJECTILE_NADE_BLUE: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_blue"); break;
328 case PROJECTILE_NADE_BLUE_BURN: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_blue_burn"); break;
329 case PROJECTILE_NADE_YELLOW: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_yellow"); break;
330 case PROJECTILE_NADE_YELLOW_BURN: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_yellow_burn"); break;
331 case PROJECTILE_NADE_PINK: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_pink"); break;
332 case PROJECTILE_NADE_PINK_BURN: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_pink_burn"); break;
333 case PROJECTILE_NADE: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade"); break;
334 case PROJECTILE_NADE_BURN: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_burn"); break;
337 error("Received invalid CSQC projectile, can't work with this!");
343 self.colormod = '0 0 0';
344 self.move_touch = SUB_Stop;
345 self.move_movetype = MOVETYPE_TOSS;
350 case PROJECTILE_ELECTRO:
351 // only new engines support sound moving with object
352 loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTEN_NORM);
353 self.mins = '0 0 -4';
354 self.maxs = '0 0 -4';
355 self.move_movetype = MOVETYPE_BOUNCE;
356 self.move_touch = func_null;
357 self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
358 self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
360 case PROJECTILE_ROCKET:
361 loopsound(self, CH_SHOTS_SINGLE, "weapons/rocket_fly.wav", VOL_BASE, ATTEN_NORM);
362 self.mins = '-3 -3 -3';
365 case PROJECTILE_GRENADE:
366 self.mins = '-3 -3 -3';
369 case PROJECTILE_NADE_RED_BURN:
370 case PROJECTILE_NADE_RED:
371 case PROJECTILE_NADE_BLUE_BURN:
372 case PROJECTILE_NADE_BLUE:
373 self.mins = '-3 -3 -3';
375 self.move_movetype = MOVETYPE_BOUNCE;
376 self.move_touch = func_null;
378 self.avelocity = randomvec() * 720;
380 case PROJECTILE_GRENADE_BOUNCING:
381 self.mins = '-3 -3 -3';
383 self.move_movetype = MOVETYPE_BOUNCE;
384 self.move_touch = func_null;
385 self.move_bounce_factor = g_balance_grenadelauncher_bouncefactor;
386 self.move_bounce_stopspeed = g_balance_grenadelauncher_bouncestop;
388 case PROJECTILE_NADE_RED_BURN:
389 case PROJECTILE_NADE_RED:
390 case PROJECTILE_NADE_BLUE_BURN:
391 case PROJECTILE_NADE_BLUE:
392 case PROJECTILE_NADE_YELLOW_BURN:
393 case PROJECTILE_NADE_YELLOW:
394 case PROJECTILE_NADE_PINK_BURN:
395 case PROJECTILE_NADE_PINK:
396 case PROJECTILE_NADE_BURN:
397 case PROJECTILE_NADE:
398 self.mins = '-16 -16 -16';
399 self.maxs = '16 16 16';
400 self.move_movetype = MOVETYPE_BOUNCE;
401 self.move_touch = func_null;
403 self.avelocity = randomvec() * 720;
405 case PROJECTILE_SHAMBLER_LIGHTNING:
406 self.mins = '-8 -8 -8';
409 self.avelocity = randomvec() * 720;
411 case PROJECTILE_MINE:
412 self.mins = '-4 -4 -4';
415 case PROJECTILE_PORTO_RED:
416 self.colormod = '2 1 1';
418 self.move_movetype = MOVETYPE_BOUNCE;
419 self.move_touch = func_null;
421 case PROJECTILE_PORTO_BLUE:
422 self.colormod = '1 1 2';
424 self.move_movetype = MOVETYPE_BOUNCE;
425 self.move_touch = func_null;
427 case PROJECTILE_HAGAR_BOUNCING:
428 self.move_movetype = MOVETYPE_BOUNCE;
429 self.move_touch = func_null;
431 case PROJECTILE_CRYLINK_BOUNCING:
432 self.move_movetype = MOVETYPE_BOUNCE;
433 self.move_touch = func_null;
435 case PROJECTILE_FIREBALL:
436 loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly2.wav", VOL_BASE, ATTEN_NORM);
437 self.mins = '-16 -16 -16';
438 self.maxs = '16 16 16';
440 case PROJECTILE_FIREMINE:
441 loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly.wav", VOL_BASE, ATTEN_NORM);
442 self.move_movetype = MOVETYPE_BOUNCE;
443 self.move_touch = func_null;
444 self.mins = '-4 -4 -4';
448 self.mins = '-2 -2 -2';
451 case PROJECTILE_FLAC:
452 self.mins = '-2 -2 -2';
455 case PROJECTILE_SEEKER:
456 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTEN_NORM);
457 self.mins = '-4 -4 -4';
460 case PROJECTILE_RAPTORBOMB:
461 self.mins = '-3 -3 -3';
464 case PROJECTILE_RAPTORBOMBLET:
466 case PROJECTILE_RAPTORCANNON:
468 case PROJECTILE_SPIDERROCKET:
469 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTEN_NORM);
471 case PROJECTILE_WAKIROCKET:
472 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTEN_NORM);
475 case PROJECTILE_WAKICANNON:
477 case PROJECTILE_BUMBLE_GUN:
478 // only new engines support sound moving with object
479 loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTEN_NORM);
480 self.mins = '0 0 -4';
481 self.maxs = '0 0 -4';
482 self.move_movetype = MOVETYPE_BOUNCE;
483 self.move_touch = func_null;
484 self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
485 self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
491 setsize(self, self.mins, self.maxs);
496 if(self.move_movetype == MOVETYPE_FLY)
497 self.move_movetype = MOVETYPE_TOSS;
498 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
499 self.move_movetype = MOVETYPE_BOUNCE;
503 if(self.move_movetype == MOVETYPE_TOSS)
504 self.move_movetype = MOVETYPE_FLY;
505 if(self.move_movetype == MOVETYPE_BOUNCE)
506 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
509 if(!(self.count & 0x80))
510 InterpolateOrigin_Note();
512 self.draw = Projectile_Draw;
513 self.entremove = Ent_RemoveProjectile;
516 void Projectile_Precache()
518 precache_model("models/ebomb.mdl");
519 precache_model("models/elaser.mdl");
520 precache_model("models/grenademodel.md3");
521 precache_model("models/mine.md3");
522 precache_model("models/hagarmissile.mdl");
523 precache_model("models/hlac_bullet.md3");
524 precache_model("models/laser.mdl");
525 precache_model("models/plasmatrail.mdl");
526 precache_model("models/rocket.md3");
527 precache_model("models/tagrocket.md3");
528 precache_model("models/tracer.mdl");
530 precache_model("models/weapons/v_ok_grenade.md3");
532 precache_sound("weapons/electro_fly.wav");
533 precache_sound("weapons/rocket_fly.wav");
534 precache_sound("weapons/fireball_fly.wav");
535 precache_sound("weapons/fireball_fly2.wav");
536 precache_sound("weapons/tag_rocket_fly.wav");