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:
44 case PROJECTILE_ROCKET:
45 trailparticles(self, particleeffectnum("TR_ROCKET"), from, to);
47 case PROJECTILE_CRYLINK:
48 trailparticles(self, particleeffectnum("TR_CRYLINKPLASMA"), from, to);
50 case PROJECTILE_CRYLINK_BOUNCING:
51 trailparticles(self, particleeffectnum("TR_CRYLINKPLASMA"), from, to);
53 case PROJECTILE_ELECTRO:
54 trailparticles(self, particleeffectnum("TR_NEXUIZPLASMA"), from, to);
56 case PROJECTILE_ELECTRO_BEAM:
57 trailparticles(self, particleeffectnum("TR_NEXUIZPLASMA"), from, to);
59 case PROJECTILE_GRENADE:
60 trailparticles(self, particleeffectnum("TR_KNIGHTSPIKE"), from, to);
62 case PROJECTILE_GRENADE_BOUNCING:
63 trailparticles(self, particleeffectnum("TR_KNIGHTSPIKE"), from, to);
65 case PROJECTILE_PORTO_RED:
66 trailparticles(self, particleeffectnum("TR_WIZSPIKE"), from, to);
68 case PROJECTILE_PORTO_BLUE:
69 trailparticles(self, particleeffectnum("TR_WIZSPIKE"), from, to);
71 case PROJECTILE_HOOKBOMB:
72 trailparticles(self, particleeffectnum("TR_KNIGHTSPIKE"), from, to);
74 case PROJECTILE_HAGAR:
75 trailparticles(self, particleeffectnum("TR_GRENADE"), from, to);
77 case PROJECTILE_HAGAR_BOUNCING:
78 trailparticles(self, particleeffectnum("TR_GRENADE"), from, to);
80 case PROJECTILE_BULLET:
81 trailparticles(self, particleeffectnum("tr_bullet"), from, to);
83 case PROJECTILE_BULLET_GLOWING:
84 trailparticles(self, particleeffectnum("tr_rifle"), from, to);
86 case PROJECTILE_FIREMINE:
87 trailparticles(self, particleeffectnum("firemine"), from, to);
89 case PROJECTILE_FIREBALL:
90 trailparticles(self, particleeffectnum("fireball"), from, to);
97 void Projectile_Draw()
107 if(self.count & 0x80)
109 //self.move_flags &~= FL_ONGROUND;
110 Movetype_Physics_MatchServer();
111 if(!(self.move_flags & FL_ONGROUND))
112 self.angles = vectoangles(self.velocity);
116 InterpolateOrigin_Do();
119 if(self.count & 0x80)
121 drawn = (time >= self.spawntime - 0.02);
122 t = max(time, self.spawntime);
126 drawn = (self.iflags & IFLAG_VALID);
130 if(!(f & FL_ONGROUND))
136 case PROJECTILE_GRENADE:
137 rot = '-2000 0 0'; // forward
140 case PROJECTILE_GRENADE_BOUNCING:
141 rot = '0 -1000 0'; // sideways
143 case PROJECTILE_HOOKBOMB:
144 rot = '1000 0 0'; // forward
149 self.angles = AnglesTransform_Multiply(self.angles, rot * (t - self.spawntime));
152 fixedmakevectors(self.angles);
154 trailorigin = self.origin;
157 case PROJECTILE_GRENADE:
158 case PROJECTILE_GRENADE_BOUNCING:
159 trailorigin += v_right * 1 + v_forward * -10;
165 Projectile_DrawTrail(trailorigin);
168 self.trail_oldorigin = trailorigin;
169 self.trail_oldtime = time;
178 case PROJECTILE_BULLET_GLOWING:
179 R_AddDynamicLight(self.origin, 50, '1 1 0');
186 self.renderflags = 0;
191 void loopsound(entity e, float ch, string samp, float vol, float attn)
196 sound(e, ch, samp, vol, attn);
200 void Ent_RemoveProjectile()
203 sound(self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
205 if(self.count & 0x80)
207 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
208 Projectile_DrawTrail(trace_endpos);
212 void Ent_Projectile()
216 // projectile properties:
217 // kind (interpolated, or clientside)
225 // soundindex (hardcoded list)
228 // projectiles don't send angles, because they always follow the velocity
231 self.count = (f & 0x80);
232 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES;
233 self.solid = SOLID_TRIGGER;
234 //self.effects = EF_NOMODELFLAGS;
236 // this should make collisions with bmodels more exact, but it leads to
237 // projectiles no longer being able to lie on a bmodel
238 self.move_nomonsters = MOVE_WORLDONLY;
240 self.move_flags |= FL_ONGROUND;
242 self.move_flags &~= FL_ONGROUND;
246 // for some unknown reason, we don't need to care for
247 // sv_gameplayfix_delayprojectiles here.
248 self.move_time = time;
249 self.spawntime = time;
252 self.move_time = max(self.move_time, time);
254 if(!(self.count & 0x80))
255 InterpolateOrigin_Undo();
259 self.origin_x = ReadCoord();
260 self.origin_y = ReadCoord();
261 self.origin_z = ReadCoord();
262 if(self.count & 0x80)
264 self.velocity_x = ReadCoord();
265 self.velocity_y = ReadCoord();
266 self.velocity_z = ReadCoord();
267 self.gravity = ReadCoord();
269 self.move_origin = self.origin;
270 self.move_velocity = self.velocity;
273 if(time == self.spawntime || (self.count & 0x80) || (f & 0x20))
274 self.trail_oldorigin = self.origin;
279 self.cnt = ReadByte();
281 self.silent = (self.cnt & 0x80);
282 self.cnt = (self.cnt & 0x7F);
287 case PROJECTILE_ELECTRO: setmodel(self, "models/ebomb.mdl"); break;
288 case PROJECTILE_ROCKET: setmodel(self, "models/rocket.md3"); self.scale = 2; break;
289 case PROJECTILE_BULLET: setmodel(self, "models/tracer.mdl"); break;
290 case PROJECTILE_BULLET_GLOWING: setmodel(self, "models/tracer.mdl"); break;
291 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl"); break;
292 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl"); break;
293 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl"); break;
294 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3"); break;
295 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3"); break;
296 case PROJECTILE_LASER: setmodel(self, "models/laser.mdl"); break;
297 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3"); break;
298 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3"); self.scale = 4; break;
299 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3"); self.scale = 4; break;
300 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3"); break;
301 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; break;
302 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl"); self.scale = 0.4; break;
303 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; break; // particle effect is good enough
304 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; break; // particle effect is good enough
306 error("Received invalid CSQC projectile, can't work with this!");
312 self.colormod = '0 0 0';
313 self.move_touch = SUB_Stop;
314 self.move_movetype = MOVETYPE_TOSS;
318 case PROJECTILE_ELECTRO:
319 // only new engines support sound moving with object
320 loopsound(self, CHAN_PROJECTILE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
321 self.mins = '0 0 -3';
322 self.maxs = '0 0 -3';
323 self.move_movetype = MOVETYPE_BOUNCE;
324 self.move_touch = SUB_Null;
326 case PROJECTILE_ROCKET:
327 loopsound(self, CHAN_PROJECTILE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
328 self.mins = '-3 -3 -3';
331 case PROJECTILE_GRENADE:
332 self.mins = '0 0 -3';
333 self.maxs = '0 0 -3';
335 case PROJECTILE_GRENADE_BOUNCING:
336 self.mins = '0 0 -3';
337 self.maxs = '0 0 -3';
338 self.move_movetype = MOVETYPE_BOUNCE;
339 self.move_touch = SUB_Null;
341 case PROJECTILE_PORTO_RED:
342 self.colormod = '2 1 1';
344 self.move_movetype = MOVETYPE_BOUNCE;
345 self.move_touch = SUB_Null;
347 case PROJECTILE_PORTO_BLUE:
348 self.colormod = '1 1 2';
350 self.move_movetype = MOVETYPE_BOUNCE;
351 self.move_touch = SUB_Null;
353 case PROJECTILE_HAGAR_BOUNCING:
354 self.move_movetype = MOVETYPE_BOUNCE;
355 self.move_touch = SUB_Null;
357 case PROJECTILE_CRYLINK_BOUNCING:
358 self.move_movetype = MOVETYPE_BOUNCE;
359 self.move_touch = SUB_Null;
361 case PROJECTILE_FIREBALL:
362 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
363 self.mins = '-16 -16 -16';
364 self.maxs = '16 16 16';
366 case PROJECTILE_FIREMINE:
367 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
368 self.move_movetype = MOVETYPE_BOUNCE;
369 self.move_touch = SUB_Null;
370 self.mins = '-4 -4 -4';
380 if(self.move_movetype == MOVETYPE_FLY)
381 self.move_movetype = MOVETYPE_TOSS;
382 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
383 self.move_movetype = MOVETYPE_BOUNCE;
387 if(self.move_movetype == MOVETYPE_TOSS)
388 self.move_movetype = MOVETYPE_FLY;
389 if(self.move_movetype == MOVETYPE_BOUNCE)
390 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
393 if(!(self.count & 0x80))
394 InterpolateOrigin_Note();
396 self.draw = Projectile_Draw;
397 self.entremove = Ent_RemoveProjectile;
400 void Projectile_Precache()
402 precache_model("models/ebomb.mdl");
403 precache_model("models/elaser.mdl");
404 precache_model("models/grenademodel.md3");
405 precache_model("models/hagarmissile.mdl");
406 precache_model("models/hlac_bullet.md3");
407 precache_model("models/laser.mdl");
408 precache_model("models/plasmatrail.mdl");
409 precache_model("models/rocket.md3");
410 precache_model("models/tracer.mdl");
411 precache_sound("weapons/electro_fly.wav");
412 precache_sound("weapons/rocket_fly.wav");
413 precache_sound("weapons/fireball_fly.wav");
414 precache_sound("weapons/fireball_fly2.wav");