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;
30 void Projectile_DrawTrail(vector to)
34 from = self.trail_oldorigin;
35 t0 = self.trail_oldtime;
36 self.trail_oldorigin = to;
37 self.trail_oldtime = time;
39 // force the effect even for stationary firemine
40 if(self.cnt == PROJECTILE_FIREMINE)
46 particles_alphamin = particles_alphamax = sqrt(self.alpha);
47 boxparticles(self.traileffect, self, from, to, self.velocity, self.velocity, sqrt(self.alpha), PARTICLES_USEALPHA);
51 void Projectile_Draw()
64 //self.move_flags &~= FL_ONGROUND;
65 if(self.move_movetype == MOVETYPE_NONE || self.move_movetype == MOVETYPE_FLY)
66 Movetype_Physics_NoMatchServer();
67 // the trivial movetypes do not have to match the
68 // server's ticrate as they are ticrate independent
69 // NOTE: this assumption is only true if MOVETYPE_FLY
70 // projectiles detonate on impact. If they continue
71 // moving, we might still be ticrate dependent.
73 Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
74 if(!(self.move_flags & FL_ONGROUND))
75 if(self.velocity != '0 0 0')
76 self.angles = vectoangles(self.velocity);
80 InterpolateOrigin_Do();
85 drawn = (time >= self.spawntime - 0.02);
86 t = max(time, self.spawntime);
90 drawn = (self.iflags & IFLAG_VALID);
94 if(!(f & FL_ONGROUND))
100 case PROJECTILE_GRENADE:
101 rot = '-2000 0 0'; // forward
104 case PROJECTILE_GRENADE_BOUNCING:
105 rot = '0 -1000 0'; // sideways
107 case PROJECTILE_HOOKBOMB:
108 rot = '1000 0 0'; // forward
113 self.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(self.angles), rot * (t - self.spawntime)));
121 a = 1 - (time - self.fade_time) * self.fade_rate;
122 self.alpha = bound(0, self.alphamod * a, 1);
125 self.renderflags = 0;
127 trailorigin = self.origin;
130 case PROJECTILE_GRENADE:
131 case PROJECTILE_GRENADE_BOUNCING:
132 trailorigin += v_right * 1 + v_forward * -10;
138 Projectile_DrawTrail(trailorigin);
140 Projectile_ResetTrail(trailorigin);
149 case PROJECTILE_BULLET_GLOWING:
150 case PROJECTILE_BULLET_GLOWING_TRACER:
151 R_AddDynamicLight(self.origin, 50 * a, '1 1 0');
157 self.drawmask = MASK_NORMAL;
160 void loopsound(entity e, float ch, string samp, float vol, float attn)
165 sound(e, ch, samp, vol, attn);
169 void Ent_RemoveProjectile()
172 sound(self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
174 if(self.count & 0x80)
176 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
177 Projectile_DrawTrail(trace_endpos);
181 void Ent_Projectile()
185 // projectile properties:
186 // kind (interpolated, or clientside)
194 // soundindex (hardcoded list)
197 // projectiles don't send angles, because they always follow the velocity
200 self.count = (f & 0x80);
201 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES;
202 self.solid = SOLID_TRIGGER;
203 //self.effects = EF_NOMODELFLAGS;
205 // this should make collisions with bmodels more exact, but it leads to
206 // projectiles no longer being able to lie on a bmodel
207 self.move_nomonsters = MOVE_WORLDONLY;
209 self.move_flags |= FL_ONGROUND;
211 self.move_flags &~= FL_ONGROUND;
215 // for some unknown reason, we don't need to care for
216 // sv_gameplayfix_delayprojectiles here.
217 self.move_time = time;
218 self.spawntime = time;
221 self.move_time = max(self.move_time, time);
223 if(!(self.count & 0x80))
224 InterpolateOrigin_Undo();
228 self.origin_x = ReadCoord();
229 self.origin_y = ReadCoord();
230 self.origin_z = ReadCoord();
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);
265 self.cnt = ReadByte();
267 self.silent = (self.cnt & 0x80);
268 self.cnt = (self.cnt & 0x7F);
271 self.traileffect = 0;
274 case PROJECTILE_ELECTRO: setmodel(self, "models/ebomb.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
275 case PROJECTILE_ROCKET: setmodel(self, "models/rocket.md3");self.traileffect = particleeffectnum("TR_ROCKET"); self.scale = 2; break;
276 case PROJECTILE_BULLET: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_bullet"); break;
277 case PROJECTILE_BULLET_GLOWING: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle_weak"); break;
278 case PROJECTILE_BULLET_GLOWING_TRACER: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle"); break;
279 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
280 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
281 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
282 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
283 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
284 case PROJECTILE_MINE: setmodel(self, "models/mine.md3");self.traileffect = particleeffectnum(""); break;
285 case PROJECTILE_LASER: setmodel(self, "models/laser.mdl");self.traileffect = particleeffectnum(""); break;
286 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3");self.traileffect = particleeffectnum(""); break;
287 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
288 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
289 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_KNIGHTSPIKE"); break;
290 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("TR_GRENADE"); self.scale = 0.4; break;
291 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("TR_GRENADE"); self.scale = 0.4; 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_ROCKET"); break;
296 case PROJECTILE_SEEKER: setmodel(self, "models/tagrocket.md3"); self.scale = 2; self.traileffect = particleeffectnum("TR_ROCKET"); break;
297 case PROJECTILE_RAPTORBOMB: setmodel(self, "models/vehicles/raptor_bomb.dpm"); self.gravity = 1; self.avelocity = '0 0 180'; self.traileffect = particleeffectnum("TR_GRENADE"); break;
299 error("Received invalid CSQC projectile, can't work with this!");
305 self.colormod = '0 0 0';
306 self.move_touch = SUB_Stop;
307 self.move_movetype = MOVETYPE_TOSS;
312 case PROJECTILE_ELECTRO:
313 // only new engines support sound moving with object
314 loopsound(self, CHAN_PROJECTILE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
315 self.mins = '0 0 -4';
316 self.maxs = '0 0 -4';
317 self.move_movetype = MOVETYPE_BOUNCE;
318 self.move_touch = SUB_Null;
319 self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
320 self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
322 case PROJECTILE_ROCKET:
323 loopsound(self, CHAN_PROJECTILE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
324 self.mins = '-3 -3 -3';
327 case PROJECTILE_GRENADE:
328 self.mins = '-3 -3 -3';
331 case PROJECTILE_GRENADE_BOUNCING:
332 self.mins = '-3 -3 -3';
334 self.move_movetype = MOVETYPE_BOUNCE;
335 self.move_touch = SUB_Null;
336 self.move_bounce_factor = g_balance_grenadelauncher_bouncefactor;
337 self.move_bounce_stopspeed = g_balance_grenadelauncher_bouncestop;
339 case PROJECTILE_MINE:
340 self.mins = '-4 -4 -4';
343 case PROJECTILE_PORTO_RED:
344 self.colormod = '2 1 1';
346 self.move_movetype = MOVETYPE_BOUNCE;
347 self.move_touch = SUB_Null;
349 case PROJECTILE_PORTO_BLUE:
350 self.colormod = '1 1 2';
352 self.move_movetype = MOVETYPE_BOUNCE;
353 self.move_touch = SUB_Null;
355 case PROJECTILE_HAGAR_BOUNCING:
356 self.move_movetype = MOVETYPE_BOUNCE;
357 self.move_touch = SUB_Null;
359 case PROJECTILE_CRYLINK_BOUNCING:
360 self.move_movetype = MOVETYPE_BOUNCE;
361 self.move_touch = SUB_Null;
363 case PROJECTILE_FIREBALL:
364 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
365 self.mins = '-16 -16 -16';
366 self.maxs = '16 16 16';
368 case PROJECTILE_FIREMINE:
369 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
370 self.move_movetype = MOVETYPE_BOUNCE;
371 self.move_touch = SUB_Null;
372 self.mins = '-4 -4 -4';
376 loopsound(self, CHAN_PROJECTILE, "weapons/tag_rocket_fly.wav", VOL_BASE, ATTN_NORM);
377 self.mins = '-2 -2 -2';
380 case PROJECTILE_FLAC:
381 self.mins = '-2 -2 -2';
384 case PROJECTILE_SEEKER:
385 self.mins = '-4 -4 -4';
388 case PROJECTILE_RAPTORBOMB:
389 self.mins = '-3 -3 -3';
399 if(self.move_movetype == MOVETYPE_FLY)
400 self.move_movetype = MOVETYPE_TOSS;
401 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
402 self.move_movetype = MOVETYPE_BOUNCE;
406 if(self.move_movetype == MOVETYPE_TOSS)
407 self.move_movetype = MOVETYPE_FLY;
408 if(self.move_movetype == MOVETYPE_BOUNCE)
409 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
412 if(!(self.count & 0x80))
413 InterpolateOrigin_Note();
415 self.draw = Projectile_Draw;
416 self.entremove = Ent_RemoveProjectile;
419 void Projectile_Precache()
421 precache_model("models/ebomb.mdl");
422 precache_model("models/elaser.mdl");
423 precache_model("models/grenademodel.md3");
424 precache_model("models/mine.md3");
425 precache_model("models/hagarmissile.mdl");
426 precache_model("models/hlac_bullet.md3");
427 precache_model("models/laser.mdl");
428 precache_model("models/plasmatrail.mdl");
429 precache_model("models/rocket.md3");
430 precache_model("models/tagrocket.md3");
431 precache_model("models/tracer.mdl");
432 precache_model("models/vehicles/raptor_bomb.dpm");
434 precache_sound("weapons/electro_fly.wav");
435 precache_sound("weapons/rocket_fly.wav");
436 precache_sound("weapons/fireball_fly.wav");
437 precache_sound("weapons/fireball_fly2.wav");
438 precache_sound("weapons/tag_rocket_fly.wav");