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 = sqrt(self.alpha);
44 boxparticles(self.traileffect, self, from, to, self.velocity, self.velocity, sqrt(self.alpha), PARTICLES_USEALPHA);
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 rot = self.avelocity;
110 case PROJECTILE_HOOKBOMB:
111 rot = '1000 0 0'; // forward
116 self.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(self.angles), rot * (t - self.spawntime)));
124 a = 1 - (time - self.fade_time) * self.fade_rate;
125 self.alpha = bound(0, self.alphamod * a, 1);
128 self.renderflags = 0;
130 trailorigin = self.origin;
133 case PROJECTILE_NADE_RED:
134 case PROJECTILE_NADE_RED_BURN:
135 case PROJECTILE_NADE_BLUE:
136 case PROJECTILE_NADE_BLUE_BURN:
137 trailorigin += v_up * 4;
139 case PROJECTILE_GRENADE:
140 case PROJECTILE_GRENADE_BOUNCING:
141 trailorigin += v_right * 1 + v_forward * -10;
147 Projectile_DrawTrail(trailorigin);
149 Projectile_ResetTrail(trailorigin);
158 case PROJECTILE_BULLET_GLOWING:
159 case PROJECTILE_BULLET_GLOWING_TRACER:
160 adddynamiclight(self.origin, 50 * a, '1 1 0');
166 self.drawmask = MASK_NORMAL;
169 void loopsound(entity e, float ch, string samp, float vol, float attn)
174 sound(e, ch, samp, vol, attn);
178 void Ent_RemoveProjectile()
180 if(self.count & 0x80)
182 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
183 Projectile_DrawTrail(trace_endpos);
187 void Ent_Projectile()
191 // projectile properties:
192 // kind (interpolated, or clientside)
200 // soundindex (hardcoded list)
203 // projectiles don't send angles, because they always follow the velocity
206 self.count = (f & 0x80);
207 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES | IFLAG_ORIGIN;
208 self.solid = SOLID_TRIGGER;
209 //self.effects = EF_NOMODELFLAGS;
211 // this should make collisions with bmodels more exact, but it leads to
212 // projectiles no longer being able to lie on a bmodel
213 self.move_nomonsters = MOVE_WORLDONLY;
215 self.move_flags |= FL_ONGROUND;
217 self.move_flags &~= FL_ONGROUND;
221 // for some unknown reason, we don't need to care for
222 // sv_gameplayfix_delayprojectiles here.
223 self.move_time = time;
224 self.spawntime = time;
227 self.move_time = max(self.move_time, time);
229 if(!(self.count & 0x80))
230 InterpolateOrigin_Undo();
234 self.origin_x = ReadCoord();
235 self.origin_y = ReadCoord();
236 self.origin_z = ReadCoord();
237 setorigin(self, self.origin);
238 if(self.count & 0x80)
240 self.velocity_x = ReadCoord();
241 self.velocity_y = ReadCoord();
242 self.velocity_z = ReadCoord();
244 self.gravity = ReadCoord();
246 self.gravity = 0; // none
247 self.move_origin = self.origin;
248 self.move_velocity = self.velocity;
251 if(time == self.spawntime || (self.count & 0x80) || (f & 0x08))
253 self.trail_oldorigin = self.origin;
254 if(!(self.count & 0x80))
255 InterpolateOrigin_Reset();
260 self.fade_time = time + ReadByte() * ticrate;
261 self.fade_rate = 1 / (ReadByte() * ticrate);
272 self.cnt = ReadByte();
274 self.silent = (self.cnt & 0x80);
275 self.cnt = (self.cnt & 0x7F);
278 self.traileffect = 0;
281 case PROJECTILE_ELECTRO: setmodel(self, "models/ebomb.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
282 case PROJECTILE_ROCKET: setmodel(self, "models/rocket.md3");self.traileffect = particleeffectnum("TR_ROCKET"); self.scale = 2; break;
283 case PROJECTILE_BULLET: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_bullet"); break;
284 case PROJECTILE_BULLET_GLOWING: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle_weak"); break;
285 case PROJECTILE_BULLET_GLOWING_TRACER: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle"); break;
286 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
287 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
288 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
289 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
290 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
291 case PROJECTILE_MINE: setmodel(self, "models/mine.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
292 case PROJECTILE_LASER: setmodel(self, "models/laser.mdl");self.traileffect = particleeffectnum(""); break;
293 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3");self.traileffect = particleeffectnum(""); break;
294 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
295 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
296 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_KNIGHTSPIKE"); break;
297 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("tr_hagar"); self.scale = 0.75; break;
298 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("tr_hagar"); self.scale = 0.75; break;
299 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("fireball"); break; // particle effect is good enough
300 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("firemine"); break; // particle effect is good enough
301 case PROJECTILE_TAG: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum("TR_ROCKET"); break;
302 case PROJECTILE_FLAC: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; self.traileffect = particleeffectnum("TR_SEEKER"); break;
303 case PROJECTILE_SEEKER: setmodel(self, "models/tagrocket.md3"); self.traileffect = particleeffectnum("TR_SEEKER"); break;
305 case PROJECTILE_RAPTORBOMB: setmodel(self, "models/vehicles/clusterbomb.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
306 case PROJECTILE_RAPTORBOMBLET: setmodel(self, "models/vehicles/bomblet.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
307 case PROJECTILE_RAPTORCANNON: setmodel(self, "models/plasmatrail.mdl"); self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
309 case PROJECTILE_SPIDERROCKET: setmodel(self, "models/vehicles/rocket02.md3"); self.traileffect = particleeffectnum("spiderbot_rocket_thrust"); break;
310 case PROJECTILE_WAKIROCKET: setmodel(self, "models/vehicles/rocket01.md3"); self.traileffect = particleeffectnum("wakizashi_rocket_thrust"); break;
311 case PROJECTILE_WAKICANNON: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum(""); break;
313 case PROJECTILE_BUMBLE_GUN: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
314 case PROJECTILE_BUMBLE_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
316 case PROJECTILE_NADE_RED: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_red"); break;
317 case PROJECTILE_NADE_RED_BURN: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_red_burn"); break;
318 case PROJECTILE_NADE_BLUE: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_blue"); break;
319 case PROJECTILE_NADE_BLUE_BURN: setmodel(self, "models/weapons/v_ok_grenade.md3");self.traileffect = particleeffectnum("nade_blue_burn"); break;
322 error("Received invalid CSQC projectile, can't work with this!");
328 self.colormod = '0 0 0';
329 self.move_touch = SUB_Stop;
330 self.move_movetype = MOVETYPE_TOSS;
335 case PROJECTILE_ELECTRO:
336 // only new engines support sound moving with object
337 loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
338 self.mins = '0 0 -4';
339 self.maxs = '0 0 -4';
340 self.move_movetype = MOVETYPE_BOUNCE;
341 self.move_touch = func_null;
342 self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
343 self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
345 case PROJECTILE_ROCKET:
346 loopsound(self, CH_SHOTS_SINGLE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
347 self.mins = '-3 -3 -3';
350 case PROJECTILE_GRENADE:
351 self.mins = '-3 -3 -3';
354 case PROJECTILE_NADE_RED_BURN:
355 case PROJECTILE_NADE_RED:
356 case PROJECTILE_NADE_BLUE_BURN:
357 case PROJECTILE_NADE_BLUE:
358 self.mins = '-3 -3 -3';
360 self.move_movetype = MOVETYPE_BOUNCE;
361 self.move_touch = func_null;
363 self.avelocity = randomvec() * 720;
365 case PROJECTILE_GRENADE_BOUNCING:
366 self.mins = '-3 -3 -3';
368 self.move_movetype = MOVETYPE_BOUNCE;
369 self.move_touch = func_null;
370 self.move_bounce_factor = g_balance_grenadelauncher_bouncefactor;
371 self.move_bounce_stopspeed = g_balance_grenadelauncher_bouncestop;
373 case PROJECTILE_MINE:
374 self.mins = '-4 -4 -4';
377 case PROJECTILE_PORTO_RED:
378 self.colormod = '2 1 1';
380 self.move_movetype = MOVETYPE_BOUNCE;
381 self.move_touch = func_null;
383 case PROJECTILE_PORTO_BLUE:
384 self.colormod = '1 1 2';
386 self.move_movetype = MOVETYPE_BOUNCE;
387 self.move_touch = func_null;
389 case PROJECTILE_HAGAR_BOUNCING:
390 self.move_movetype = MOVETYPE_BOUNCE;
391 self.move_touch = func_null;
393 case PROJECTILE_CRYLINK_BOUNCING:
394 self.move_movetype = MOVETYPE_BOUNCE;
395 self.move_touch = func_null;
397 case PROJECTILE_FIREBALL:
398 loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
399 self.mins = '-16 -16 -16';
400 self.maxs = '16 16 16';
402 case PROJECTILE_FIREMINE:
403 loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
404 self.move_movetype = MOVETYPE_BOUNCE;
405 self.move_touch = func_null;
406 self.mins = '-4 -4 -4';
410 self.mins = '-2 -2 -2';
413 case PROJECTILE_FLAC:
414 self.mins = '-2 -2 -2';
417 case PROJECTILE_SEEKER:
418 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
419 self.mins = '-4 -4 -4';
422 case PROJECTILE_RAPTORBOMB:
423 self.mins = '-3 -3 -3';
426 case PROJECTILE_RAPTORBOMBLET:
428 case PROJECTILE_RAPTORCANNON:
430 case PROJECTILE_SPIDERROCKET:
431 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
433 case PROJECTILE_WAKIROCKET:
434 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
437 case PROJECTILE_WAKICANNON:
439 case PROJECTILE_BUMBLE_GUN:
440 // only new engines support sound moving with object
441 loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
442 self.mins = '0 0 -4';
443 self.maxs = '0 0 -4';
444 self.move_movetype = MOVETYPE_BOUNCE;
445 self.move_touch = func_null;
446 self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
447 self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
453 setsize(self, self.mins, self.maxs);
458 if(self.move_movetype == MOVETYPE_FLY)
459 self.move_movetype = MOVETYPE_TOSS;
460 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
461 self.move_movetype = MOVETYPE_BOUNCE;
465 if(self.move_movetype == MOVETYPE_TOSS)
466 self.move_movetype = MOVETYPE_FLY;
467 if(self.move_movetype == MOVETYPE_BOUNCE)
468 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
471 if(!(self.count & 0x80))
472 InterpolateOrigin_Note();
474 self.draw = Projectile_Draw;
475 self.entremove = Ent_RemoveProjectile;
478 void Projectile_Precache()
480 precache_model("models/ebomb.mdl");
481 precache_model("models/elaser.mdl");
482 precache_model("models/grenademodel.md3");
483 precache_model("models/mine.md3");
484 precache_model("models/hagarmissile.mdl");
485 precache_model("models/hlac_bullet.md3");
486 precache_model("models/laser.mdl");
487 precache_model("models/plasmatrail.mdl");
488 precache_model("models/rocket.md3");
489 precache_model("models/tagrocket.md3");
490 precache_model("models/tracer.mdl");
492 precache_sound("weapons/electro_fly.wav");
493 precache_sound("weapons/rocket_fly.wav");
494 precache_sound("weapons/fireball_fly.wav");
495 precache_sound("weapons/fireball_fly2.wav");
496 precache_sound("weapons/tag_rocket_fly.wav");