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_DrawTrail(vector to)
29 from = self.trail_oldorigin;
30 t0 = self.trail_oldtime;
31 self.trail_oldorigin = to;
32 self.trail_oldtime = time;
34 // force the effect even for stationary firemine
35 if(self.cnt == PROJECTILE_FIREMINE)
41 if(checkextension("DP_CSQC_BOXPARTICLES"))
43 /* looks good, but we can do better with particle count
44 particles_alphamin = particles_alphamax = self.alpha;
45 boxparticles(self.traileffect, self, from, to, self.velocity, self.velocity, 1, PARTICLES_USEALPHA);
48 boxparticles(self.traileffect, self, from, to, self.velocity, self.velocity, self.alpha, 0);
50 particles_alphamin = particles_alphamax = sqrt(self.alpha);
51 boxparticles(self.traileffect, self, from, to, self.velocity, self.velocity, sqrt(self.alpha), PARTICLES_USEALPHA);
54 trailparticles(self, self.traileffect, from, to);
58 void Projectile_Draw()
71 //self.move_flags &~= FL_ONGROUND;
72 if(self.move_movetype == MOVETYPE_NONE || self.move_movetype == MOVETYPE_FLY)
73 Movetype_Physics_NoMatchServer();
74 // the trivial movetypes do not have to match the
75 // server's ticrate as they are ticrate independent
76 // NOTE: this assumption is only true if MOVETYPE_FLY
77 // projectiles detonate on impact. If they continue
78 // moving, we might still be ticrate dependent.
80 Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
81 if(!(self.move_flags & FL_ONGROUND))
82 self.angles = vectoangles(self.velocity);
86 InterpolateOrigin_Do();
91 drawn = (time >= self.spawntime - 0.02);
92 t = max(time, self.spawntime);
96 drawn = (self.iflags & IFLAG_VALID);
100 if(!(f & FL_ONGROUND))
106 case PROJECTILE_GRENADE:
107 rot = '-2000 0 0'; // forward
110 case PROJECTILE_GRENADE_BOUNCING:
111 rot = '0 -1000 0'; // sideways
113 case PROJECTILE_HOOKBOMB:
114 rot = '1000 0 0'; // forward
119 self.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(self.angles), rot * (t - self.spawntime)));
127 a = 1 - (time - self.fade_time) * self.fade_rate;
128 self.alpha = bound(0, self.alphamod * a, 1);
131 self.renderflags = 0;
133 trailorigin = self.origin;
136 case PROJECTILE_GRENADE:
137 case PROJECTILE_GRENADE_BOUNCING:
138 trailorigin += v_right * 1 + v_forward * -10;
144 Projectile_DrawTrail(trailorigin);
147 self.trail_oldorigin = trailorigin;
148 self.trail_oldtime = time;
156 case PROJECTILE_BULLET_GLOWING:
157 case PROJECTILE_BULLET_GLOWING_TRACER:
158 R_AddDynamicLight(self.origin, 50 * a, '1 1 0');
167 void loopsound(entity e, float ch, string samp, float vol, float attn)
172 sound(e, ch, samp, vol, attn);
176 void Ent_RemoveProjectile()
179 sound(self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
181 if(self.count & 0x80)
183 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
184 Projectile_DrawTrail(trace_endpos);
188 void Ent_Projectile()
192 // projectile properties:
193 // kind (interpolated, or clientside)
201 // soundindex (hardcoded list)
204 // projectiles don't send angles, because they always follow the velocity
207 self.count = (f & 0x80);
208 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES;
209 self.solid = SOLID_TRIGGER;
210 //self.effects = EF_NOMODELFLAGS;
212 // this should make collisions with bmodels more exact, but it leads to
213 // projectiles no longer being able to lie on a bmodel
214 self.move_nomonsters = MOVE_WORLDONLY;
216 self.move_flags |= FL_ONGROUND;
218 self.move_flags &~= FL_ONGROUND;
222 // for some unknown reason, we don't need to care for
223 // sv_gameplayfix_delayprojectiles here.
224 self.move_time = time;
225 self.spawntime = time;
228 self.move_time = max(self.move_time, time);
230 if(!(self.count & 0x80))
231 InterpolateOrigin_Undo();
235 self.origin_x = ReadCoord();
236 self.origin_y = ReadCoord();
237 self.origin_z = ReadCoord();
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_bullet"); 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_LASER: setmodel(self, "models/laser.mdl");self.traileffect = particleeffectnum(""); break;
292 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3");self.traileffect = particleeffectnum(""); break;
293 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
294 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
295 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_KNIGHTSPIKE"); break;
296 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("TR_GRENADE"); self.scale = 0.4; break;
297 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("TR_GRENADE"); self.scale = 0.4; break;
298 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("fireball"); break; // particle effect is good enough
299 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("firemine"); break; // particle effect is good enough
300 case PROJECTILE_TAG: setmodel(self, "models/laser.mdl"); self.traileffect = particleeffectnum("TR_ROCKET"); break;
301 case PROJECTILE_FLAC: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; self.traileffect = particleeffectnum("TR_ROCKET"); break;
302 case PROJECTILE_SEEKER: setmodel(self, "models/tagrocket.md3"); self.scale = 2; self.traileffect = particleeffectnum("TR_ROCKET"); break;
304 error("Received invalid CSQC projectile, can't work with this!");
310 self.colormod = '0 0 0';
311 self.move_touch = SUB_Stop;
312 self.move_movetype = MOVETYPE_TOSS;
317 case PROJECTILE_ELECTRO:
318 // only new engines support sound moving with object
319 loopsound(self, CHAN_PROJECTILE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
320 self.mins = '0 0 -3';
321 self.maxs = '0 0 -3';
322 self.move_movetype = MOVETYPE_BOUNCE;
323 self.move_touch = SUB_Null;
325 case PROJECTILE_ROCKET:
326 loopsound(self, CHAN_PROJECTILE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
327 self.mins = '-3 -3 -3';
330 case PROJECTILE_GRENADE:
331 self.mins = '0 0 -3';
332 self.maxs = '0 0 -3';
334 case PROJECTILE_GRENADE_BOUNCING:
335 self.mins = '0 0 -3';
336 self.maxs = '0 0 -3';
337 self.move_movetype = MOVETYPE_BOUNCE;
338 self.move_touch = SUB_Null;
339 self.move_bounce_factor = g_balance_grenadelauncher_secondary_bouncefactor;
340 self.move_bounce_stopspeed = g_balance_grenadelauncher_secondary_bouncestop;
342 case PROJECTILE_PORTO_RED:
343 self.colormod = '2 1 1';
345 self.move_movetype = MOVETYPE_BOUNCE;
346 self.move_touch = SUB_Null;
348 case PROJECTILE_PORTO_BLUE:
349 self.colormod = '1 1 2';
351 self.move_movetype = MOVETYPE_BOUNCE;
352 self.move_touch = SUB_Null;
354 case PROJECTILE_HAGAR_BOUNCING:
355 self.move_movetype = MOVETYPE_BOUNCE;
356 self.move_touch = SUB_Null;
358 case PROJECTILE_CRYLINK_BOUNCING:
359 self.move_movetype = MOVETYPE_BOUNCE;
360 self.move_touch = SUB_Null;
362 case PROJECTILE_FIREBALL:
363 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
364 self.mins = '-16 -16 -16';
365 self.maxs = '16 16 16';
367 case PROJECTILE_FIREMINE:
368 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
369 self.move_movetype = MOVETYPE_BOUNCE;
370 self.move_touch = SUB_Null;
371 self.mins = '-4 -4 -4';
375 loopsound(self, CHAN_PROJECTILE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
376 self.mins = '-2 -2 -2';
379 case PROJECTILE_FLAC:
380 self.mins = '-2 -2 -2';
383 case PROJECTILE_SEEKER:
384 self.mins = '-4 -4 -4';
394 if(self.move_movetype == MOVETYPE_FLY)
395 self.move_movetype = MOVETYPE_TOSS;
396 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
397 self.move_movetype = MOVETYPE_BOUNCE;
401 if(self.move_movetype == MOVETYPE_TOSS)
402 self.move_movetype = MOVETYPE_FLY;
403 if(self.move_movetype == MOVETYPE_BOUNCE)
404 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
407 if(!(self.count & 0x80))
408 InterpolateOrigin_Note();
410 self.draw = Projectile_Draw;
411 self.entremove = Ent_RemoveProjectile;
414 void Projectile_Precache()
416 precache_model("models/ebomb.mdl");
417 precache_model("models/elaser.mdl");
418 precache_model("models/grenademodel.md3");
419 precache_model("models/hagarmissile.mdl");
420 precache_model("models/hlac_bullet.md3");
421 precache_model("models/laser.mdl");
422 precache_model("models/plasmatrail.mdl");
423 precache_model("models/rocket.md3");
424 precache_model("models/tagrocket.md3");
425 precache_model("models/tracer.mdl");
426 precache_sound("weapons/electro_fly.wav");
427 precache_sound("weapons/rocket_fly.wav");
428 precache_sound("weapons/fireball_fly.wav");
429 precache_sound("weapons/fireball_fly2.wav");
430 precache_sound("weapons/tag_rocket_fly.wav");