2 .vector trail_oldorigin;
11 self.move_velocity = self.move_avelocity = '0 0 0';
12 self.move_movetype = MOVETYPE_NONE;
15 .float count; // set if clientside projectile
16 .float cnt; // sound index
21 void Projectile_DrawTrail(vector to)
25 from = self.trail_oldorigin;
26 t0 = self.trail_oldtime;
27 self.trail_oldorigin = to;
28 self.trail_oldtime = time;
34 case PROJECTILE_FIREMINE:
37 case PROJECTILE_ELECTRO:
38 trailparticles(self, particleeffectnum("TR_NEXUIZPLASMA"), from, to);
47 case PROJECTILE_ROCKET:
48 trailparticles(self, particleeffectnum("TR_ROCKET"), from, to);
50 case PROJECTILE_CRYLINK:
51 trailparticles(self, particleeffectnum("TR_CRYLINKPLASMA"), from, to);
53 case PROJECTILE_CRYLINK_BOUNCING:
54 trailparticles(self, particleeffectnum("TR_CRYLINKPLASMA"), from, to);
56 case PROJECTILE_ELECTRO:
57 trailparticles(self, particleeffectnum("TR_NEXUIZPLASMA"), from, to);
59 case PROJECTILE_ELECTRO_BEAM:
60 trailparticles(self, particleeffectnum("TR_NEXUIZPLASMA"), from, to);
62 case PROJECTILE_GRENADE:
63 trailparticles(self, particleeffectnum("TR_KNIGHTSPIKE"), from, to);
65 case PROJECTILE_GRENADE_BOUNCING:
66 trailparticles(self, particleeffectnum("TR_KNIGHTSPIKE"), from, to);
68 case PROJECTILE_PORTO_RED:
69 trailparticles(self, particleeffectnum("TR_WIZSPIKE"), from, to);
71 case PROJECTILE_PORTO_BLUE:
72 trailparticles(self, particleeffectnum("TR_WIZSPIKE"), from, to);
74 case PROJECTILE_HOOKBOMB:
75 trailparticles(self, particleeffectnum("TR_KNIGHTSPIKE"), from, to);
77 case PROJECTILE_HAGAR:
78 trailparticles(self, particleeffectnum("TR_GRENADE"), from, to);
80 case PROJECTILE_HAGAR_BOUNCING:
81 trailparticles(self, particleeffectnum("TR_GRENADE"), from, to);
83 case PROJECTILE_BULLET:
84 trailparticles(self, particleeffectnum("tr_bullet"), from, to);
86 case PROJECTILE_BULLET_GLOWING:
87 trailparticles(self, particleeffectnum("tr_rifle"), from, to);
89 case PROJECTILE_FIREMINE:
90 trailparticles(self, particleeffectnum("firemine"), from, to);
92 case PROJECTILE_FIREBALL:
93 trailparticles(self, particleeffectnum("fireball"), from, to);
100 void Projectile_Draw()
110 if(self.count & 0x80)
112 //self.move_flags &~= FL_ONGROUND;
113 Movetype_Physics_MatchServer();
114 if(!(self.move_flags & FL_ONGROUND))
115 self.angles = vectoangles(self.velocity);
119 InterpolateOrigin_Do();
122 if(self.count & 0x80)
124 drawn = (time >= self.spawntime - 0.02);
125 t = max(time, self.spawntime);
129 drawn = (self.iflags & IFLAG_VALID);
133 if(!(f & FL_ONGROUND))
139 case PROJECTILE_GRENADE:
140 rot = '-2000 0 0'; // forward
143 case PROJECTILE_GRENADE_BOUNCING:
144 rot = '0 -1000 0'; // sideways
146 case PROJECTILE_HOOKBOMB:
147 rot = '1000 0 0'; // forward
152 self.angles = AnglesTransform_Multiply(self.angles, rot * (t - self.spawntime));
155 fixedmakevectors(self.angles);
157 trailorigin = self.origin;
160 case PROJECTILE_GRENADE:
161 case PROJECTILE_GRENADE_BOUNCING:
162 trailorigin += v_right * 1 + v_forward * -10;
168 Projectile_DrawTrail(trailorigin);
171 self.trail_oldorigin = trailorigin;
172 self.trail_oldtime = time;
181 case PROJECTILE_BULLET_GLOWING:
182 R_AddDynamicLight(self.origin, 50, '1 1 0');
189 self.renderflags = 0;
194 void loopsound(entity e, float ch, string samp, float vol, float attn)
199 sound(e, ch, samp, vol, attn);
203 void Ent_RemoveProjectile()
206 sound(self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
208 if(self.count & 0x80)
210 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
211 Projectile_DrawTrail(trace_endpos);
215 void Ent_Projectile()
219 // projectile properties:
220 // kind (interpolated, or clientside)
228 // soundindex (hardcoded list)
231 // projectiles don't send angles, because they always follow the velocity
234 self.count = (f & 0x80);
235 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES;
236 self.solid = SOLID_TRIGGER;
237 //self.effects = EF_NOMODELFLAGS;
239 // this should make collisions with bmodels more exact, but it leads to
240 // projectiles no longer being able to lie on a bmodel
241 self.move_nomonsters = MOVE_WORLDONLY;
243 self.move_flags |= FL_ONGROUND;
245 self.move_flags &~= FL_ONGROUND;
249 // for some unknown reason, we don't need to care for
250 // sv_gameplayfix_delayprojectiles here.
251 self.move_time = time;
252 self.spawntime = time;
255 self.move_time = max(self.move_time, time);
257 if(!(self.count & 0x80))
258 InterpolateOrigin_Undo();
262 self.origin_x = ReadCoord();
263 self.origin_y = ReadCoord();
264 self.origin_z = ReadCoord();
265 if(self.count & 0x80)
267 self.velocity_x = ReadCoord();
268 self.velocity_y = ReadCoord();
269 self.velocity_z = ReadCoord();
270 self.gravity = ReadCoord();
272 self.move_origin = self.origin;
273 self.move_velocity = self.velocity;
276 if(time == self.spawntime || (self.count & 0x80) || (f & 0x20))
277 self.trail_oldorigin = self.origin;
282 self.cnt = ReadByte();
284 self.silent = (self.cnt & 0x80);
285 self.cnt = (self.cnt & 0x7F);
290 case PROJECTILE_ELECTRO: setmodel(self, "models/ebomb.mdl"); break;
291 case PROJECTILE_ROCKET: setmodel(self, "models/rocket.md3"); self.scale = 2; break;
292 case PROJECTILE_BULLET: setmodel(self, "models/tracer.mdl"); break;
293 case PROJECTILE_BULLET_GLOWING: setmodel(self, "models/tracer.mdl"); break;
294 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl"); break;
295 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl"); break;
296 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl"); break;
297 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3"); break;
298 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3"); break;
299 case PROJECTILE_LASER: setmodel(self, "models/laser.mdl"); break;
300 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3"); break;
301 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3"); self.scale = 4; break;
302 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3"); self.scale = 4; break;
303 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3"); break;
304 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; break;
305 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; break;
306 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; break; // particle effect is good enough
307 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; break; // particle effect is good enough
309 error("Received invalid CSQC projectile, can't work with this!");
315 self.colormod = '0 0 0';
316 self.move_touch = SUB_Stop;
317 self.move_movetype = MOVETYPE_TOSS;
321 case PROJECTILE_ELECTRO:
322 // only new engines support sound moving with object
323 loopsound(self, CHAN_PROJECTILE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
324 self.mins = '0 0 -3';
325 self.maxs = '0 0 -3';
326 self.move_movetype = MOVETYPE_BOUNCE;
327 self.move_touch = SUB_Null;
329 case PROJECTILE_ROCKET:
330 loopsound(self, CHAN_PROJECTILE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
331 self.mins = '-3 -3 -3';
334 case PROJECTILE_GRENADE:
335 self.mins = '0 0 -3';
336 self.maxs = '0 0 -3';
338 case PROJECTILE_GRENADE_BOUNCING:
339 self.mins = '0 0 -3';
340 self.maxs = '0 0 -3';
341 self.move_movetype = MOVETYPE_BOUNCE;
342 self.move_touch = SUB_Null;
344 case PROJECTILE_PORTO_RED:
345 self.colormod = '2 1 1';
347 self.move_movetype = MOVETYPE_BOUNCE;
348 self.move_touch = SUB_Null;
350 case PROJECTILE_PORTO_BLUE:
351 self.colormod = '1 1 2';
353 self.move_movetype = MOVETYPE_BOUNCE;
354 self.move_touch = SUB_Null;
356 case PROJECTILE_HAGAR_BOUNCING:
357 self.move_movetype = MOVETYPE_BOUNCE;
358 self.move_touch = SUB_Null;
360 case PROJECTILE_CRYLINK_BOUNCING:
361 self.move_movetype = MOVETYPE_BOUNCE;
362 self.move_touch = SUB_Null;
364 case PROJECTILE_FIREBALL:
365 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
366 self.mins = '-16 -16 -16';
367 self.maxs = '16 16 16';
369 case PROJECTILE_FIREMINE:
370 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
371 self.move_movetype = MOVETYPE_BOUNCE;
372 self.move_touch = SUB_Null;
373 self.mins = '-4 -4 -4';
383 if(self.move_movetype == MOVETYPE_FLY)
384 self.move_movetype = MOVETYPE_TOSS;
385 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
386 self.move_movetype = MOVETYPE_BOUNCE;
390 if(self.move_movetype == MOVETYPE_TOSS)
391 self.move_movetype = MOVETYPE_FLY;
392 if(self.move_movetype == MOVETYPE_BOUNCE)
393 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
396 if(!(self.count & 0x80))
397 InterpolateOrigin_Note();
399 self.draw = Projectile_Draw;
400 self.entremove = Ent_RemoveProjectile;
403 void Projectile_Precache()
405 precache_model("models/ebomb.mdl");
406 precache_model("models/elaser.mdl");
407 precache_model("models/grenademodel.md3");
408 precache_model("models/hagarmissile.mdl");
409 precache_model("models/hlac_bullet.md3");
410 precache_model("models/laser.mdl");
411 precache_model("models/plasmatrail.mdl");
412 precache_model("models/rocket.md3");
413 precache_model("models/tracer.mdl");
414 precache_sound("weapons/electro_fly.wav");
415 precache_sound("weapons/rocket_fly.wav");
416 precache_sound("weapons/fireball_fly.wav");
417 precache_sound("weapons/fireball_fly2.wav");