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_HOOKBOMB:
105 rot = '1000 0 0'; // forward
110 self.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(self.angles), rot * (t - self.spawntime)));
118 a = 1 - (time - self.fade_time) * self.fade_rate;
119 self.alpha = bound(0, self.alphamod * a, 1);
122 self.renderflags = 0;
124 trailorigin = self.origin;
127 case PROJECTILE_GRENADE:
128 case PROJECTILE_GRENADE_BOUNCING:
129 trailorigin += v_right * 1 + v_forward * -10;
135 Projectile_DrawTrail(trailorigin);
137 Projectile_ResetTrail(trailorigin);
146 case PROJECTILE_BULLET_GLOWING:
147 case PROJECTILE_BULLET_GLOWING_TRACER:
148 adddynamiclight(self.origin, 50 * a, '1 1 0');
154 self.drawmask = MASK_NORMAL;
157 void loopsound(entity e, float ch, string samp, float vol, float attn)
162 sound(e, ch, samp, vol, attn);
166 void Ent_RemoveProjectile()
168 if(self.count & 0x80)
170 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
171 Projectile_DrawTrail(trace_endpos);
175 void Ent_Projectile()
179 // projectile properties:
180 // kind (interpolated, or clientside)
188 // soundindex (hardcoded list)
191 // projectiles don't send angles, because they always follow the velocity
194 self.count = (f & 0x80);
195 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES;
196 self.solid = SOLID_TRIGGER;
197 //self.effects = EF_NOMODELFLAGS;
199 // this should make collisions with bmodels more exact, but it leads to
200 // projectiles no longer being able to lie on a bmodel
201 self.move_nomonsters = MOVE_WORLDONLY;
203 self.move_flags |= FL_ONGROUND;
205 self.move_flags &~= FL_ONGROUND;
209 // for some unknown reason, we don't need to care for
210 // sv_gameplayfix_delayprojectiles here.
211 self.move_time = time;
212 self.spawntime = time;
215 self.move_time = max(self.move_time, time);
217 if(!(self.count & 0x80))
218 InterpolateOrigin_Undo();
222 self.origin_x = ReadCoord();
223 self.origin_y = ReadCoord();
224 self.origin_z = ReadCoord();
225 setorigin(self, self.origin);
226 if(self.count & 0x80)
228 self.velocity_x = ReadCoord();
229 self.velocity_y = ReadCoord();
230 self.velocity_z = ReadCoord();
232 self.gravity = ReadCoord();
234 self.gravity = 0; // none
235 self.move_origin = self.origin;
236 self.move_velocity = self.velocity;
239 if(time == self.spawntime || (self.count & 0x80) || (f & 0x08))
241 self.trail_oldorigin = self.origin;
242 if(!(self.count & 0x80))
243 InterpolateOrigin_Reset();
248 self.fade_time = time + ReadByte() * ticrate;
249 self.fade_rate = 1 / (ReadByte() * ticrate);
260 self.cnt = ReadByte();
262 self.silent = (self.cnt & 0x80);
263 self.cnt = (self.cnt & 0x7F);
266 self.traileffect = 0;
269 case PROJECTILE_ELECTRO: setmodel(self, "models/ebomb.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
270 case PROJECTILE_ROCKET: setmodel(self, "models/rocket.md3");self.traileffect = particleeffectnum("TR_ROCKET"); self.scale = 2; break;
271 case PROJECTILE_BULLET: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_bullet"); break;
272 case PROJECTILE_BULLET_GLOWING: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle_weak"); break;
273 case PROJECTILE_BULLET_GLOWING_TRACER: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle"); break;
274 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
275 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
276 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
277 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
278 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
279 case PROJECTILE_MINE: setmodel(self, "models/mine.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
280 case PROJECTILE_LASER: setmodel(self, "models/laser.mdl");self.traileffect = particleeffectnum(""); break;
281 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3");self.traileffect = particleeffectnum(""); break;
282 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
283 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
284 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_KNIGHTSPIKE"); break;
285 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("tr_hagar"); self.scale = 0.75; break;
286 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("tr_hagar"); self.scale = 0.75; break;
287 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("fireball"); break; // particle effect is good enough
288 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("firemine"); break; // particle effect is good enough
289 case PROJECTILE_TAG: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum("TR_ROCKET"); break;
290 case PROJECTILE_FLAC: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; self.traileffect = particleeffectnum("TR_SEEKER"); break;
291 case PROJECTILE_SEEKER: setmodel(self, "models/tagrocket.md3"); self.traileffect = particleeffectnum("TR_SEEKER"); break;
293 case PROJECTILE_RAPTORBOMB: setmodel(self, "models/vehicles/clusterbomb.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
294 case PROJECTILE_RAPTORBOMBLET: setmodel(self, "models/vehicles/bomblet.md3"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum(""); break;
295 case PROJECTILE_RAPTORCANNON: setmodel(self, "models/plasmatrail.mdl"); self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
297 case PROJECTILE_SPIDERROCKET: setmodel(self, "models/vehicles/rocket02.md3"); self.traileffect = particleeffectnum("spiderbot_rocket_thrust"); break;
298 case PROJECTILE_WAKIROCKET: setmodel(self, "models/vehicles/rocket01.md3"); self.traileffect = particleeffectnum("wakizashi_rocket_thrust"); break;
299 case PROJECTILE_WAKICANNON: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum(""); break;
301 case PROJECTILE_BUMBLE_GUN: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
302 case PROJECTILE_BUMBLE_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
305 error("Received invalid CSQC projectile, can't work with this!");
311 self.colormod = '0 0 0';
312 self.move_touch = SUB_Stop;
313 self.move_movetype = MOVETYPE_TOSS;
318 case PROJECTILE_ELECTRO:
319 // only new engines support sound moving with object
320 loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
321 self.mins = '0 0 -4';
322 self.maxs = '0 0 -4';
323 self.move_movetype = MOVETYPE_BOUNCE;
324 self.move_touch = func_null;
325 self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
326 self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
328 case PROJECTILE_ROCKET:
329 loopsound(self, CH_SHOTS_SINGLE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
330 self.mins = '-3 -3 -3';
333 case PROJECTILE_GRENADE:
334 self.mins = '-3 -3 -3';
337 case PROJECTILE_GRENADE_BOUNCING:
338 self.mins = '-3 -3 -3';
340 self.move_movetype = MOVETYPE_BOUNCE;
341 self.move_touch = func_null;
342 self.move_bounce_factor = g_balance_grenadelauncher_bouncefactor;
343 self.move_bounce_stopspeed = g_balance_grenadelauncher_bouncestop;
345 case PROJECTILE_MINE:
346 self.mins = '-4 -4 -4';
349 case PROJECTILE_PORTO_RED:
350 self.colormod = '2 1 1';
352 self.move_movetype = MOVETYPE_BOUNCE;
353 self.move_touch = func_null;
355 case PROJECTILE_PORTO_BLUE:
356 self.colormod = '1 1 2';
358 self.move_movetype = MOVETYPE_BOUNCE;
359 self.move_touch = func_null;
361 case PROJECTILE_HAGAR_BOUNCING:
362 self.move_movetype = MOVETYPE_BOUNCE;
363 self.move_touch = func_null;
365 case PROJECTILE_CRYLINK_BOUNCING:
366 self.move_movetype = MOVETYPE_BOUNCE;
367 self.move_touch = func_null;
369 case PROJECTILE_FIREBALL:
370 loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
371 self.mins = '-16 -16 -16';
372 self.maxs = '16 16 16';
374 case PROJECTILE_FIREMINE:
375 loopsound(self, CH_SHOTS_SINGLE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
376 self.move_movetype = MOVETYPE_BOUNCE;
377 self.move_touch = func_null;
378 self.mins = '-4 -4 -4';
382 self.mins = '-2 -2 -2';
385 case PROJECTILE_FLAC:
386 self.mins = '-2 -2 -2';
389 case PROJECTILE_SEEKER:
390 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
391 self.mins = '-4 -4 -4';
394 case PROJECTILE_RAPTORBOMB:
395 self.mins = '-3 -3 -3';
398 case PROJECTILE_RAPTORBOMBLET:
400 case PROJECTILE_RAPTORCANNON:
402 case PROJECTILE_SPIDERROCKET:
403 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
405 case PROJECTILE_WAKIROCKET:
406 loopsound(self, CH_SHOTS_SINGLE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
409 case PROJECTILE_WAKICANNON:
411 case PROJECTILE_BUMBLE_GUN:
412 // only new engines support sound moving with object
413 loopsound(self, CH_SHOTS_SINGLE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
414 self.mins = '0 0 -4';
415 self.maxs = '0 0 -4';
416 self.move_movetype = MOVETYPE_BOUNCE;
417 self.move_touch = func_null;
418 self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
419 self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
425 setsize(self, self.mins, self.maxs);
430 if(self.move_movetype == MOVETYPE_FLY)
431 self.move_movetype = MOVETYPE_TOSS;
432 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
433 self.move_movetype = MOVETYPE_BOUNCE;
437 if(self.move_movetype == MOVETYPE_TOSS)
438 self.move_movetype = MOVETYPE_FLY;
439 if(self.move_movetype == MOVETYPE_BOUNCE)
440 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
443 if(!(self.count & 0x80))
444 InterpolateOrigin_Note();
446 self.draw = Projectile_Draw;
447 self.entremove = Ent_RemoveProjectile;
450 void Projectile_Precache()
452 precache_model("models/ebomb.mdl");
453 precache_model("models/elaser.mdl");
454 precache_model("models/grenademodel.md3");
455 precache_model("models/mine.md3");
456 precache_model("models/hagarmissile.mdl");
457 precache_model("models/hlac_bullet.md3");
458 precache_model("models/laser.mdl");
459 precache_model("models/plasmatrail.mdl");
460 precache_model("models/rocket.md3");
461 precache_model("models/tagrocket.md3");
462 precache_model("models/tracer.mdl");
464 precache_sound("weapons/electro_fly.wav");
465 precache_sound("weapons/rocket_fly.wav");
466 precache_sound("weapons/fireball_fly.wav");
467 precache_sound("weapons/fireball_fly2.wav");
468 precache_sound("weapons/tag_rocket_fly.wav");