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_HOOKBOMB:
105 rot = '1000 0 0'; // forward
111 if(Nade_IDFromProjectile(self.cnt) != 0)
112 rot = self.avelocity;
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 if(Nade_IDFromProjectile(self.cnt) != 0)
140 trailorigin += v_up * 4;
143 Projectile_DrawTrail(trailorigin);
145 Projectile_ResetTrail(trailorigin);
154 // Possibly add dlights here.
159 self.drawmask = MASK_NORMAL;
162 void loopsound(entity e, float ch, string samp, float vol, float attn)
167 sound(e, ch, samp, vol, attn);
171 void Ent_RemoveProjectile()
173 if(self.count & 0x80)
175 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
176 Projectile_DrawTrail(trace_endpos);
180 void Ent_Projectile()
184 // projectile properties:
185 // kind (interpolated, or clientside)
193 // soundindex (hardcoded list)
196 // projectiles don't send angles, because they always follow the velocity
199 self.count = (f & 0x80);
200 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES | IFLAG_ORIGIN;
201 self.solid = SOLID_TRIGGER;
202 //self.effects = EF_NOMODELFLAGS;
204 // this should make collisions with bmodels more exact, but it leads to
205 // projectiles no longer being able to lie on a bmodel
206 self.move_nomonsters = MOVE_WORLDONLY;
208 self.move_flags |= FL_ONGROUND;
210 self.move_flags &= ~FL_ONGROUND;
214 // for some unknown reason, we don't need to care for
215 // sv_gameplayfix_delayprojectiles here.
216 self.move_time = time;
217 self.spawntime = time;
220 self.move_time = max(self.move_time, time);
222 if(!(self.count & 0x80))
223 InterpolateOrigin_Undo();
227 self.origin_x = ReadCoord();
228 self.origin_y = ReadCoord();
229 self.origin_z = ReadCoord();
230 setorigin(self, self.origin);
231 if(self.count & 0x80)
233 self.velocity_x = ReadCoord();
234 self.velocity_y = ReadCoord();
235 self.velocity_z = ReadCoord();
237 self.gravity = ReadCoord();
239 self.gravity = 0; // none
240 self.move_origin = self.origin;
241 self.move_velocity = self.velocity;
244 if(time == self.spawntime || (self.count & 0x80) || (f & 0x08))
246 self.trail_oldorigin = self.origin;
247 if(!(self.count & 0x80))
248 InterpolateOrigin_Reset();
253 self.fade_time = time + ReadByte() * ticrate;
254 self.fade_rate = 1 / (ReadByte() * ticrate);
262 self.team = ReadByte() - 1;
267 self.cnt = ReadByte();
269 self.silent = (self.cnt & 0x80);
270 self.cnt = (self.cnt & 0x7F);
273 self.traileffect = 0;
276 case PROJECTILE_ELECTRO: setmodel(self, "models/ebomb.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
277 case PROJECTILE_ROCKET: setmodel(self, "models/rocket.md3");self.traileffect = particleeffectnum("TR_ROCKET"); self.scale = 2; break;
278 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
279 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
280 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
281 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
282 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
283 case PROJECTILE_MINE: setmodel(self, "models/mine.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
284 case PROJECTILE_LASER: setmodel(self, "models/laser.mdl");self.traileffect = particleeffectnum(""); break;
285 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3");self.traileffect = particleeffectnum(""); break;
286 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
287 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
288 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_KNIGHTSPIKE"); break;
289 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("tr_hagar"); self.scale = 0.75; break;
290 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("tr_hagar"); self.scale = 0.75; break;
291 case PROJECTILE_NAPALM_FOUNTAIN: //self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("torch_small"); break;
292 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("fireball"); break; // particle effect is good enough
293 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("firemine"); break; // particle effect is good enough
294 case PROJECTILE_TAG: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum("TR_ROCKET"); break;
295 case PROJECTILE_FLAC: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; self.traileffect = particleeffectnum("TR_SEEKER"); break;
296 case PROJECTILE_SEEKER: setmodel(self, "models/tagrocket.md3"); self.traileffect = particleeffectnum("TR_SEEKER"); break;
298 case PROJECTILE_MAGE_SPIKE: setmodel(self, "models/ebomb.mdl"); self.traileffect = particleeffectnum("TR_VORESPIKE"); break;
299 case PROJECTILE_SHAMBLER_LIGHTNING: setmodel(self, "models/ebomb.mdl"); self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
301 case PROJECTILE_RAPTORBOMB: setmodel(self, "models/vehicles/clusterbomb.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
302 case PROJECTILE_RAPTORBOMBLET: setmodel(self, "models/vehicles/bomblet.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
303 case PROJECTILE_RAPTORCANNON: setmodel(self, "models/plasmatrail.mdl"); self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
305 case PROJECTILE_SPIDERROCKET: setmodel(self, "models/vehicles/rocket02.md3"); self.traileffect = particleeffectnum("spiderbot_rocket_thrust"); break;
306 case PROJECTILE_WAKIROCKET: setmodel(self, "models/vehicles/rocket01.md3"); self.traileffect = particleeffectnum("wakizashi_rocket_thrust"); break;
307 case PROJECTILE_WAKICANNON: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum(""); break;
309 case PROJECTILE_BUMBLE_GUN: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
310 case PROJECTILE_BUMBLE_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
313 if(Nade_IDFromProjectile(self.cnt) != 0) { setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum(Nade_TrailEffect(self.cnt, self.team)); break; }
314 error("Received invalid CSQC projectile, can't work with this!");
320 self.colormod = '0 0 0';
321 self.move_touch = SUB_Stop;
322 self.move_movetype = MOVETYPE_TOSS;
327 case PROJECTILE_ELECTRO:
328 // only new engines support sound moving with object
329 loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTEN_NORM);
330 self.mins = '0 0 -4';
331 self.maxs = '0 0 -4';
332 self.move_movetype = MOVETYPE_BOUNCE;
333 self.move_touch = func_null;
334 self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
335 self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
337 case PROJECTILE_ROCKET:
338 loopsound(self, CH_SHOTS_SINGLE, "weapons/rocket_fly.wav", VOL_BASE, ATTEN_NORM);
339 self.mins = '-3 -3 -3';
342 case PROJECTILE_GRENADE:
343 self.mins = '-3 -3 -3';
346 case PROJECTILE_GRENADE_BOUNCING:
347 self.mins = '-3 -3 -3';
349 self.move_movetype = MOVETYPE_BOUNCE;
350 self.move_touch = func_null;
351 self.move_bounce_factor = g_balance_grenadelauncher_bouncefactor;
352 self.move_bounce_stopspeed = g_balance_grenadelauncher_bouncestop;
354 case PROJECTILE_SHAMBLER_LIGHTNING:
355 self.mins = '-8 -8 -8';
358 self.avelocity = randomvec() * 720;
360 case PROJECTILE_MINE:
361 self.mins = '-4 -4 -4';
364 case PROJECTILE_PORTO_RED:
365 self.colormod = '2 1 1';
367 self.move_movetype = MOVETYPE_BOUNCE;
368 self.move_touch = func_null;
370 case PROJECTILE_PORTO_BLUE:
371 self.colormod = '1 1 2';
373 self.move_movetype = MOVETYPE_BOUNCE;
374 self.move_touch = func_null;
376 case PROJECTILE_HAGAR_BOUNCING:
377 self.move_movetype = MOVETYPE_BOUNCE;
378 self.move_touch = func_null;
380 case PROJECTILE_CRYLINK_BOUNCING:
381 self.move_movetype = MOVETYPE_BOUNCE;
382 self.move_touch = func_null;
384 case PROJECTILE_NAPALM_FOUNTAIN:
385 case PROJECTILE_FIREBALL:
386 loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly2.wav", VOL_BASE, ATTEN_NORM);
387 self.mins = '-16 -16 -16';
388 self.maxs = '16 16 16';
390 case PROJECTILE_FIREMINE:
391 loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly.wav", VOL_BASE, ATTEN_NORM);
392 self.move_movetype = MOVETYPE_BOUNCE;
393 self.move_touch = func_null;
394 self.mins = '-4 -4 -4';
398 self.mins = '-2 -2 -2';
401 case PROJECTILE_FLAC:
402 self.mins = '-2 -2 -2';
405 case PROJECTILE_SEEKER:
406 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTEN_NORM);
407 self.mins = '-4 -4 -4';
410 case PROJECTILE_RAPTORBOMB:
411 self.mins = '-3 -3 -3';
414 case PROJECTILE_RAPTORBOMBLET:
416 case PROJECTILE_RAPTORCANNON:
418 case PROJECTILE_SPIDERROCKET:
419 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTEN_NORM);
421 case PROJECTILE_WAKIROCKET:
422 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTEN_NORM);
425 case PROJECTILE_WAKICANNON:
427 case PROJECTILE_BUMBLE_GUN:
428 // only new engines support sound moving with object
429 loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTEN_NORM);
430 self.mins = '0 0 -4';
431 self.maxs = '0 0 -4';
432 self.move_movetype = MOVETYPE_BOUNCE;
433 self.move_touch = func_null;
434 self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
435 self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
442 if(Nade_IDFromProjectile(self.cnt) != 0)
444 self.mins = '-16 -16 -16';
445 self.maxs = '16 16 16';
446 self.colormod = Nade_Color(Nade_IDFromProjectile(self.cnt));
447 self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
448 self.move_movetype = MOVETYPE_BOUNCE;
449 self.move_touch = func_null;
451 self.avelocity = randomvec() * 720;
453 if(Nade_IDFromProjectile(self.cnt) == NADE_TYPE_TRANSLOCATE)
454 self.solid = SOLID_TRIGGER;
457 setsize(self, self.mins, self.maxs);
462 if(self.move_movetype == MOVETYPE_FLY)
463 self.move_movetype = MOVETYPE_TOSS;
464 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
465 self.move_movetype = MOVETYPE_BOUNCE;
469 if(self.move_movetype == MOVETYPE_TOSS)
470 self.move_movetype = MOVETYPE_FLY;
471 if(self.move_movetype == MOVETYPE_BOUNCE)
472 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
475 if(!(self.count & 0x80))
476 InterpolateOrigin_Note();
478 self.draw = Projectile_Draw;
479 self.entremove = Ent_RemoveProjectile;
482 void Projectile_Precache()
484 precache_model("models/ebomb.mdl");
485 precache_model("models/elaser.mdl");
486 precache_model("models/grenademodel.md3");
487 precache_model("models/mine.md3");
488 precache_model("models/hagarmissile.mdl");
489 precache_model("models/hlac_bullet.md3");
490 precache_model("models/laser.mdl");
491 precache_model("models/plasmatrail.mdl");
492 precache_model("models/rocket.md3");
493 precache_model("models/tagrocket.md3");
494 precache_model("models/tracer.mdl");
495 precache_model("models/sphere/sphere.md3");
497 precache_model("models/weapons/v_ok_grenade.md3");
499 precache_sound("weapons/electro_fly.wav");
500 precache_sound("weapons/rocket_fly.wav");
501 precache_sound("weapons/fireball_fly.wav");
502 precache_sound("weapons/fireball_fly2.wav");
503 precache_sound("weapons/tag_rocket_fly.wav");