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;
35 trailparticles(self, self.traileffect, from, to);
38 void Projectile_Draw()
51 //self.move_flags &~= FL_ONGROUND;
52 Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
53 if(!(self.move_flags & FL_ONGROUND))
54 self.angles = vectoangles(self.velocity);
58 InterpolateOrigin_Do();
63 drawn = (time >= self.spawntime - 0.02);
64 t = max(time, self.spawntime);
68 drawn = (self.iflags & IFLAG_VALID);
72 if(!(f & FL_ONGROUND))
78 case PROJECTILE_GRENADE:
79 rot = '-2000 0 0'; // forward
82 case PROJECTILE_GRENADE_BOUNCING:
83 rot = '0 -1000 0'; // sideways
85 case PROJECTILE_HOOKBOMB:
86 rot = '1000 0 0'; // forward
91 self.angles = AnglesTransform_ToAngles(AnglesTransform_Multiply(AnglesTransform_FromAngles(self.angles), rot * (t - self.spawntime)));
99 a = 1 - (time - self.fade_time) * self.fade_rate;
103 trailorigin = self.origin;
106 case PROJECTILE_GRENADE:
107 case PROJECTILE_GRENADE_BOUNCING:
108 trailorigin += v_right * 1 + v_forward * -10;
114 Projectile_DrawTrail(trailorigin);
117 self.trail_oldorigin = trailorigin;
118 self.trail_oldtime = time;
126 case PROJECTILE_BULLET_GLOWING:
127 case PROJECTILE_BULLET_GLOWING_TRACER:
128 R_AddDynamicLight(self.origin, 50 * a, '1 1 0');
134 self.alpha = self.alphamod * a;
135 self.renderflags = 0;
140 void loopsound(entity e, float ch, string samp, float vol, float attn)
145 sound(e, ch, samp, vol, attn);
149 void Ent_RemoveProjectile()
152 sound(self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
154 if(self.count & 0x80)
156 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
157 Projectile_DrawTrail(trace_endpos);
161 void Ent_Projectile()
165 // projectile properties:
166 // kind (interpolated, or clientside)
174 // soundindex (hardcoded list)
177 // projectiles don't send angles, because they always follow the velocity
180 self.count = (f & 0x80);
181 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES;
182 self.solid = SOLID_TRIGGER;
183 //self.effects = EF_NOMODELFLAGS;
185 // this should make collisions with bmodels more exact, but it leads to
186 // projectiles no longer being able to lie on a bmodel
187 self.move_nomonsters = MOVE_WORLDONLY;
189 self.move_flags |= FL_ONGROUND;
191 self.move_flags &~= FL_ONGROUND;
195 // for some unknown reason, we don't need to care for
196 // sv_gameplayfix_delayprojectiles here.
197 self.move_time = time;
198 self.spawntime = time;
201 self.move_time = max(self.move_time, time);
203 if(!(self.count & 0x80))
204 InterpolateOrigin_Undo();
208 self.origin_x = ReadCoord();
209 self.origin_y = ReadCoord();
210 self.origin_z = ReadCoord();
211 if(self.count & 0x80)
213 self.velocity_x = ReadCoord();
214 self.velocity_y = ReadCoord();
215 self.velocity_z = ReadCoord();
216 self.gravity = ReadCoord();
218 self.move_origin = self.origin;
219 self.move_velocity = self.velocity;
222 if(time == self.spawntime || (self.count & 0x80) || (f & 0x10))
224 self.trail_oldorigin = self.origin;
225 if(!(self.count & 0x80))
226 InterpolateOrigin_Reset();
231 self.fade_time = time + ReadByte() * ticrate;
232 self.fade_rate = 1 / (ReadByte() * ticrate);
243 self.cnt = ReadByte();
245 self.silent = (self.cnt & 0x80);
246 self.cnt = (self.cnt & 0x7F);
249 self.traileffect = 0;
252 case PROJECTILE_ELECTRO: setmodel(self, "models/ebomb.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
253 case PROJECTILE_ROCKET: setmodel(self, "models/rocket.md3");self.traileffect = particleeffectnum("TR_ROCKET"); self.scale = 2; break;
254 case PROJECTILE_BULLET: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_bullet"); break;
255 case PROJECTILE_BULLET_GLOWING: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_bullet"); break;
256 case PROJECTILE_BULLET_GLOWING_TRACER: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle"); break;
257 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
258 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
259 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
260 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
261 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
262 case PROJECTILE_LASER: setmodel(self, "models/laser.mdl");self.traileffect = particleeffectnum(""); break;
263 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3");self.traileffect = particleeffectnum(""); break;
264 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
265 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
266 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_KNIGHTSPIKE"); break;
267 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("TR_GRENADE"); self.scale = 0.4; break;
268 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("TR_GRENADE"); self.scale = 0.4; break;
269 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("fireball"); break; // particle effect is good enough
270 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("firemine"); break; // particle effect is good enough
272 error("Received invalid CSQC projectile, can't work with this!");
278 self.colormod = '0 0 0';
279 self.move_touch = SUB_Stop;
280 self.move_movetype = MOVETYPE_TOSS;
285 case PROJECTILE_ELECTRO:
286 // only new engines support sound moving with object
287 loopsound(self, CHAN_PROJECTILE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
288 self.mins = '0 0 -3';
289 self.maxs = '0 0 -3';
290 self.move_movetype = MOVETYPE_BOUNCE;
291 self.move_touch = SUB_Null;
293 case PROJECTILE_ROCKET:
294 loopsound(self, CHAN_PROJECTILE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
295 self.mins = '-3 -3 -3';
298 case PROJECTILE_GRENADE:
299 self.mins = '0 0 -3';
300 self.maxs = '0 0 -3';
302 case PROJECTILE_GRENADE_BOUNCING:
303 self.mins = '0 0 -3';
304 self.maxs = '0 0 -3';
305 self.move_movetype = MOVETYPE_BOUNCE;
306 self.move_touch = SUB_Null;
308 case PROJECTILE_PORTO_RED:
309 self.colormod = '2 1 1';
311 self.move_movetype = MOVETYPE_BOUNCE;
312 self.move_touch = SUB_Null;
314 case PROJECTILE_PORTO_BLUE:
315 self.colormod = '1 1 2';
317 self.move_movetype = MOVETYPE_BOUNCE;
318 self.move_touch = SUB_Null;
320 case PROJECTILE_HAGAR_BOUNCING:
321 self.move_movetype = MOVETYPE_BOUNCE;
322 self.move_touch = SUB_Null;
324 case PROJECTILE_CRYLINK_BOUNCING:
325 self.move_movetype = MOVETYPE_BOUNCE;
326 self.move_touch = SUB_Null;
328 case PROJECTILE_FIREBALL:
329 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
330 self.mins = '-16 -16 -16';
331 self.maxs = '16 16 16';
333 case PROJECTILE_FIREMINE:
334 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
335 self.move_movetype = MOVETYPE_BOUNCE;
336 self.move_touch = SUB_Null;
337 self.mins = '-4 -4 -4';
347 if(self.move_movetype == MOVETYPE_FLY)
348 self.move_movetype = MOVETYPE_TOSS;
349 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
350 self.move_movetype = MOVETYPE_BOUNCE;
354 if(self.move_movetype == MOVETYPE_TOSS)
355 self.move_movetype = MOVETYPE_FLY;
356 if(self.move_movetype == MOVETYPE_BOUNCE)
357 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
360 if(!(self.count & 0x80))
361 InterpolateOrigin_Note();
363 self.draw = Projectile_Draw;
364 self.entremove = Ent_RemoveProjectile;
367 void Projectile_Precache()
369 precache_model("models/ebomb.mdl");
370 precache_model("models/elaser.mdl");
371 precache_model("models/grenademodel.md3");
372 precache_model("models/hagarmissile.mdl");
373 precache_model("models/hlac_bullet.md3");
374 precache_model("models/laser.mdl");
375 precache_model("models/plasmatrail.mdl");
376 precache_model("models/rocket.md3");
377 precache_model("models/tracer.mdl");
378 precache_sound("weapons/electro_fly.wav");
379 precache_sound("weapons/rocket_fly.wav");
380 precache_sound("weapons/fireball_fly.wav");
381 precache_sound("weapons/fireball_fly2.wav");