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
25 void Projectile_ResetTrail(vector to)
27 self.trail_oldorigin = to;
28 self.trail_oldtime = time;
31 void Projectile_DrawTrail(vector to)
36 from = self.trail_oldorigin;
37 t0 = self.trail_oldtime;
38 self.trail_oldorigin = to;
39 self.trail_oldtime = time;
41 // force the effect even for stationary firemine
42 if(self.cnt == PROJECTILE_FIREMINE)
48 particles_alphamin = particles_alphamax = sqrt(self.alpha);
49 boxparticles(self.traileffect, self, from, to, self.velocity, self.velocity, sqrt(self.alpha), PARTICLES_USEALPHA);
53 void Projectile_Draw()
66 //self.move_flags &~= FL_ONGROUND;
67 if(self.move_movetype == MOVETYPE_NONE || self.move_movetype == MOVETYPE_FLY)
68 Movetype_Physics_NoMatchServer();
69 // the trivial movetypes do not have to match the
70 // server's ticrate as they are ticrate independent
71 // NOTE: this assumption is only true if MOVETYPE_FLY
72 // projectiles detonate on impact. If they continue
73 // moving, we might still be ticrate dependent.
75 Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
76 if(!(self.move_flags & FL_ONGROUND))
77 if(self.velocity != '0 0 0')
78 self.angles = vectoangles(self.velocity);
82 InterpolateOrigin_Do();
87 drawn = (time >= self.spawntime - 0.02);
88 t = max(time, self.spawntime);
92 drawn = (self.iflags & IFLAG_VALID);
96 if(!(f & FL_ONGROUND))
102 case PROJECTILE_GRENADE:
103 rot = '-2000 0 0'; // forward
106 case PROJECTILE_GRENADE_BOUNCING:
107 rot = '0 -1000 0'; // sideways
109 case PROJECTILE_HOOKBOMB:
110 rot = '1000 0 0'; // forward
115 self.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(self.angles), rot * (t - self.spawntime)));
123 a = 1 - (time - self.fade_time) * self.fade_rate;
124 self.alpha = bound(0, self.alphamod * a, 1);
127 self.renderflags = 0;
129 trailorigin = self.origin;
132 case PROJECTILE_GRENADE:
133 case PROJECTILE_GRENADE_BOUNCING:
134 trailorigin += v_right * 1 + v_forward * -10;
140 Projectile_DrawTrail(trailorigin);
142 Projectile_ResetTrail(trailorigin);
151 case PROJECTILE_BULLET_GLOWING:
152 case PROJECTILE_BULLET_GLOWING_TRACER:
153 adddynamiclight(self.origin, 50 * a, '1 1 0');
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()
174 sound(self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTN_NORM);
176 if(self.count & 0x80)
178 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
179 Projectile_DrawTrail(trace_endpos);
183 void Ent_Projectile()
187 // projectile properties:
188 // kind (interpolated, or clientside)
196 // soundindex (hardcoded list)
199 // projectiles don't send angles, because they always follow the velocity
202 self.count = (f & 0x80);
203 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES;
204 self.solid = SOLID_TRIGGER;
205 //self.effects = EF_NOMODELFLAGS;
207 // this should make collisions with bmodels more exact, but it leads to
208 // projectiles no longer being able to lie on a bmodel
209 self.move_nomonsters = MOVE_WORLDONLY;
211 self.move_flags |= FL_ONGROUND;
213 self.move_flags &~= FL_ONGROUND;
217 // for some unknown reason, we don't need to care for
218 // sv_gameplayfix_delayprojectiles here.
219 self.move_time = time;
220 self.spawntime = time;
223 self.move_time = max(self.move_time, time);
225 if(!(self.count & 0x80))
226 InterpolateOrigin_Undo();
230 self.origin_x = ReadCoord();
231 self.origin_y = ReadCoord();
232 self.origin_z = ReadCoord();
233 if(self.count & 0x80)
235 self.velocity_x = ReadCoord();
236 self.velocity_y = ReadCoord();
237 self.velocity_z = ReadCoord();
239 self.gravity = ReadCoord();
241 self.gravity = 0; // none
242 self.move_origin = self.origin;
243 self.move_velocity = self.velocity;
246 if(time == self.spawntime || (self.count & 0x80) || (f & 0x08))
248 self.trail_oldorigin = self.origin;
249 if(!(self.count & 0x80))
250 InterpolateOrigin_Reset();
255 self.fade_time = time + ReadByte() * ticrate;
256 self.fade_rate = 1 / (ReadByte() * ticrate);
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_BULLET: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_bullet"); break;
279 case PROJECTILE_BULLET_GLOWING: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle_weak"); break;
280 case PROJECTILE_BULLET_GLOWING_TRACER: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle"); break;
281 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
282 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
283 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
284 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
285 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
286 case PROJECTILE_MINE: setmodel(self, "models/mine.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
287 case PROJECTILE_LASER: setmodel(self, "models/laser.mdl");self.traileffect = particleeffectnum(""); break;
288 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3");self.traileffect = particleeffectnum(""); break;
289 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
290 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
291 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_KNIGHTSPIKE"); break;
292 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("TR_GRENADE"); self.scale = 0.75; break;
293 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("TR_GRENADE"); self.scale = 0.75; break;
294 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("fireball"); break; // particle effect is good enough
295 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("firemine"); break; // particle effect is good enough
296 case PROJECTILE_TAG: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum("TR_ROCKET"); break;
297 case PROJECTILE_FLAC: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; self.traileffect = particleeffectnum("TR_SEEKER"); break;
298 case PROJECTILE_SEEKER: setmodel(self, "models/tagrocket.md3"); self.traileffect = particleeffectnum("TR_SEEKER"); break;
300 case PROJECTILE_RAPTORBOMB: setmodel(self, "models/vehicles/clusterbomb.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
301 case PROJECTILE_RAPTORBOMBLET: setmodel(self, "models/vehicles/bomblet.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
302 case PROJECTILE_RAPTORCANNON: setmodel(self, "models/plasmatrail.mdl"); self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
304 case PROJECTILE_SPIDERROCKET: setmodel(self, "models/vehicles/rocket02.md3"); self.traileffect = particleeffectnum("spiderbot_rocket_thrust"); break;
305 case PROJECTILE_WAKIROCKET: setmodel(self, "models/vehicles/rocket01.md3"); self.traileffect = particleeffectnum("wakizashi_rocket_thrust"); break;
306 case PROJECTILE_WAKICANNON: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum(""); break;
308 error("Received invalid CSQC projectile, can't work with this!");
314 self.colormod = '0 0 0';
315 self.move_touch = SUB_Stop;
316 self.move_movetype = MOVETYPE_TOSS;
321 case PROJECTILE_ELECTRO:
322 // only new engines support sound moving with object
323 loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
324 self.mins = '0 0 -4';
325 self.maxs = '0 0 -4';
326 self.move_movetype = MOVETYPE_BOUNCE;
327 self.move_touch = SUB_Null;
328 self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
329 self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
331 case PROJECTILE_ROCKET:
332 loopsound(self, CH_SHOTS_SINGLE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
333 self.mins = '-3 -3 -3';
336 case PROJECTILE_GRENADE:
337 self.mins = '-3 -3 -3';
340 case PROJECTILE_GRENADE_BOUNCING:
341 self.mins = '-3 -3 -3';
343 self.move_movetype = MOVETYPE_BOUNCE;
344 self.move_touch = SUB_Null;
345 self.move_bounce_factor = g_balance_grenadelauncher_bouncefactor;
346 self.move_bounce_stopspeed = g_balance_grenadelauncher_bouncestop;
348 case PROJECTILE_MINE:
349 self.mins = '-4 -4 -4';
352 case PROJECTILE_PORTO_RED:
353 self.colormod = '2 1 1';
355 self.move_movetype = MOVETYPE_BOUNCE;
356 self.move_touch = SUB_Null;
358 case PROJECTILE_PORTO_BLUE:
359 self.colormod = '1 1 2';
361 self.move_movetype = MOVETYPE_BOUNCE;
362 self.move_touch = SUB_Null;
364 case PROJECTILE_HAGAR_BOUNCING:
365 self.move_movetype = MOVETYPE_BOUNCE;
366 self.move_touch = SUB_Null;
368 case PROJECTILE_CRYLINK_BOUNCING:
369 self.move_movetype = MOVETYPE_BOUNCE;
370 self.move_touch = SUB_Null;
372 case PROJECTILE_FIREBALL:
373 loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
374 self.mins = '-16 -16 -16';
375 self.maxs = '16 16 16';
377 case PROJECTILE_FIREMINE:
378 loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
379 self.move_movetype = MOVETYPE_BOUNCE;
380 self.move_touch = SUB_Null;
381 self.mins = '-4 -4 -4';
385 self.mins = '-2 -2 -2';
388 case PROJECTILE_FLAC:
389 self.mins = '-2 -2 -2';
392 case PROJECTILE_SEEKER:
393 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
394 self.mins = '-4 -4 -4';
397 case PROJECTILE_RAPTORBOMB:
398 self.mins = '-3 -3 -3';
401 case PROJECTILE_RAPTORBOMBLET:
403 case PROJECTILE_RAPTORCANNON:
405 case PROJECTILE_SPIDERROCKET:
406 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
408 case PROJECTILE_WAKIROCKET:
409 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
411 case PROJECTILE_WAKICANNON:
420 if(self.move_movetype == MOVETYPE_FLY)
421 self.move_movetype = MOVETYPE_TOSS;
422 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
423 self.move_movetype = MOVETYPE_BOUNCE;
427 if(self.move_movetype == MOVETYPE_TOSS)
428 self.move_movetype = MOVETYPE_FLY;
429 if(self.move_movetype == MOVETYPE_BOUNCE)
430 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
433 if(!(self.count & 0x80))
434 InterpolateOrigin_Note();
436 self.draw = Projectile_Draw;
437 self.entremove = Ent_RemoveProjectile;
440 void Projectile_Precache()
442 precache_model("models/ebomb.mdl");
443 precache_model("models/elaser.mdl");
444 precache_model("models/grenademodel.md3");
445 precache_model("models/mine.md3");
446 precache_model("models/hagarmissile.mdl");
447 precache_model("models/hlac_bullet.md3");
448 precache_model("models/laser.mdl");
449 precache_model("models/plasmatrail.mdl");
450 precache_model("models/rocket.md3");
451 precache_model("models/tagrocket.md3");
452 precache_model("models/tracer.mdl");
454 precache_sound("weapons/electro_fly.wav");
455 precache_sound("weapons/rocket_fly.wav");
456 precache_sound("weapons/fireball_fly.wav");
457 precache_sound("weapons/fireball_fly2.wav");
458 precache_sound("weapons/tag_rocket_fly.wav");