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
22 void Projectile_DrawTrail(vector to)
26 from = self.trail_oldorigin;
27 t0 = self.trail_oldtime;
28 self.trail_oldorigin = to;
29 self.trail_oldtime = time;
32 trailparticles(self, self.traileffect, from, to);
35 void Projectile_Draw()
47 //self.move_flags &~= FL_ONGROUND;
48 Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
49 if(!(self.move_flags & FL_ONGROUND))
50 self.angles = vectoangles(self.velocity);
54 InterpolateOrigin_Do();
59 drawn = (time >= self.spawntime - 0.02);
60 t = max(time, self.spawntime);
64 drawn = (self.iflags & IFLAG_VALID);
68 if(!(f & FL_ONGROUND))
74 case PROJECTILE_GRENADE:
75 rot = '-2000 0 0'; // forward
78 case PROJECTILE_GRENADE_BOUNCING:
79 rot = '0 -1000 0'; // sideways
81 case PROJECTILE_HOOKBOMB:
82 rot = '1000 0 0'; // forward
87 self.angles = AnglesTransform_Multiply(self.angles, rot * (t - self.spawntime));
90 fixedmakevectors(self.angles);
92 trailorigin = self.origin;
95 case PROJECTILE_GRENADE:
96 case PROJECTILE_GRENADE_BOUNCING:
97 trailorigin += v_right * 1 + v_forward * -10;
103 Projectile_DrawTrail(trailorigin);
106 self.trail_oldorigin = trailorigin;
107 self.trail_oldtime = time;
115 case PROJECTILE_BULLET_GLOWING:
116 case PROJECTILE_BULLET_GLOWING_TRACER:
117 R_AddDynamicLight(self.origin, 50, '1 1 0');
123 self.renderflags = 0;
128 void loopsound(entity e, float ch, string samp, float vol, float attn)
133 sound(e, ch, samp, vol, attn);
137 void Ent_RemoveProjectile()
140 sound(self, CHAN_PROJECTILE, "misc/null.wav", VOL_BASE, ATTN_NORM);
142 if(self.count & 0x80)
144 tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
145 Projectile_DrawTrail(trace_endpos);
149 void Ent_Projectile()
153 // projectile properties:
154 // kind (interpolated, or clientside)
162 // soundindex (hardcoded list)
165 // projectiles don't send angles, because they always follow the velocity
168 self.count = (f & 0x80);
169 self.iflags = (self.iflags & IFLAG_INTERNALMASK) | IFLAG_AUTOANGLES | IFLAG_ANGLES;
170 self.solid = SOLID_TRIGGER;
171 //self.effects = EF_NOMODELFLAGS;
173 // this should make collisions with bmodels more exact, but it leads to
174 // projectiles no longer being able to lie on a bmodel
175 self.move_nomonsters = MOVE_WORLDONLY;
177 self.move_flags |= FL_ONGROUND;
179 self.move_flags &~= FL_ONGROUND;
183 // for some unknown reason, we don't need to care for
184 // sv_gameplayfix_delayprojectiles here.
185 self.move_time = time;
186 self.spawntime = time;
189 self.move_time = max(self.move_time, time);
191 if(!(self.count & 0x80))
192 InterpolateOrigin_Undo();
196 self.origin_x = ReadCoord();
197 self.origin_y = ReadCoord();
198 self.origin_z = ReadCoord();
199 if(self.count & 0x80)
201 self.velocity_x = ReadCoord();
202 self.velocity_y = ReadCoord();
203 self.velocity_z = ReadCoord();
204 self.gravity = ReadCoord();
206 self.move_origin = self.origin;
207 self.move_velocity = self.velocity;
210 if(time == self.spawntime || (self.count & 0x80) || (f & 0x20))
211 self.trail_oldorigin = self.origin;
216 self.cnt = ReadByte();
218 self.silent = (self.cnt & 0x80);
219 self.cnt = (self.cnt & 0x7F);
222 self.traileffect = 0;
225 case PROJECTILE_ELECTRO: setmodel(self, "models/ebomb.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
226 case PROJECTILE_ROCKET: setmodel(self, "models/rocket.md3");self.traileffect = particleeffectnum("TR_ROCKET"); self.scale = 2; break;
227 case PROJECTILE_BULLET: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_bullet"); break;
228 case PROJECTILE_BULLET_GLOWING: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_bullet"); break;
229 case PROJECTILE_BULLET_GLOWING_TRACER: setmodel(self, "models/tracer.mdl");self.traileffect = particleeffectnum("tr_rifle"); break;
230 case PROJECTILE_CRYLINK: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
231 case PROJECTILE_CRYLINK_BOUNCING: setmodel(self, "models/plasmatrail.mdl");self.traileffect = particleeffectnum("TR_CRYLINKPLASMA"); break;
232 case PROJECTILE_ELECTRO_BEAM: setmodel(self, "models/elaser.mdl");self.traileffect = particleeffectnum("TR_NEXUIZPLASMA"); break;
233 case PROJECTILE_GRENADE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
234 case PROJECTILE_GRENADE_BOUNCING: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_GRENADE"); break;
235 case PROJECTILE_LASER: setmodel(self, "models/laser.mdl");self.traileffect = particleeffectnum(""); break;
236 case PROJECTILE_HLAC: setmodel(self, "models/hlac_bullet.md3");self.traileffect = particleeffectnum(""); break;
237 case PROJECTILE_PORTO_RED: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
238 case PROJECTILE_PORTO_BLUE: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_WIZSPIKE"); self.scale = 4; break;
239 case PROJECTILE_HOOKBOMB: setmodel(self, "models/grenademodel.md3");self.traileffect = particleeffectnum("TR_KNIGHTSPIKE"); break;
240 case PROJECTILE_HAGAR: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("TR_GRENADE"); self.scale = 0.4; break;
241 case PROJECTILE_HAGAR_BOUNCING: setmodel(self, "models/hagarmissile.mdl");self.traileffect = particleeffectnum("TR_GRENADE"); self.scale = 0.4; break;
242 case PROJECTILE_FIREBALL: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("fireball"); break; // particle effect is good enough
243 case PROJECTILE_FIREMINE: self.model = ""; self.modelindex = 0; self.traileffect = particleeffectnum("firemine"); break; // particle effect is good enough
245 error("Received invalid CSQC projectile, can't work with this!");
251 self.colormod = '0 0 0';
252 self.move_touch = SUB_Stop;
253 self.move_movetype = MOVETYPE_TOSS;
257 case PROJECTILE_ELECTRO:
258 // only new engines support sound moving with object
259 loopsound(self, CHAN_PROJECTILE, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
260 self.mins = '0 0 -3';
261 self.maxs = '0 0 -3';
262 self.move_movetype = MOVETYPE_BOUNCE;
263 self.move_touch = SUB_Null;
265 case PROJECTILE_ROCKET:
266 loopsound(self, CHAN_PROJECTILE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
267 self.mins = '-3 -3 -3';
270 case PROJECTILE_GRENADE:
271 self.mins = '0 0 -3';
272 self.maxs = '0 0 -3';
274 case PROJECTILE_GRENADE_BOUNCING:
275 self.mins = '0 0 -3';
276 self.maxs = '0 0 -3';
277 self.move_movetype = MOVETYPE_BOUNCE;
278 self.move_touch = SUB_Null;
280 case PROJECTILE_PORTO_RED:
281 self.colormod = '2 1 1';
283 self.move_movetype = MOVETYPE_BOUNCE;
284 self.move_touch = SUB_Null;
286 case PROJECTILE_PORTO_BLUE:
287 self.colormod = '1 1 2';
289 self.move_movetype = MOVETYPE_BOUNCE;
290 self.move_touch = SUB_Null;
292 case PROJECTILE_HAGAR_BOUNCING:
293 self.move_movetype = MOVETYPE_BOUNCE;
294 self.move_touch = SUB_Null;
296 case PROJECTILE_CRYLINK_BOUNCING:
297 self.move_movetype = MOVETYPE_BOUNCE;
298 self.move_touch = SUB_Null;
300 case PROJECTILE_FIREBALL:
301 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly2.wav", VOL_BASE, ATTN_NORM);
302 self.mins = '-16 -16 -16';
303 self.maxs = '16 16 16';
305 case PROJECTILE_FIREMINE:
306 loopsound(self, CHAN_PROJECTILE, "weapons/fireball_fly.wav", VOL_BASE, ATTN_NORM);
307 self.move_movetype = MOVETYPE_BOUNCE;
308 self.move_touch = SUB_Null;
309 self.mins = '-4 -4 -4';
319 if(self.move_movetype == MOVETYPE_FLY)
320 self.move_movetype = MOVETYPE_TOSS;
321 if(self.move_movetype == MOVETYPE_BOUNCEMISSILE)
322 self.move_movetype = MOVETYPE_BOUNCE;
326 if(self.move_movetype == MOVETYPE_TOSS)
327 self.move_movetype = MOVETYPE_FLY;
328 if(self.move_movetype == MOVETYPE_BOUNCE)
329 self.move_movetype = MOVETYPE_BOUNCEMISSILE;
332 if(!(self.count & 0x80))
333 InterpolateOrigin_Note();
335 self.draw = Projectile_Draw;
336 self.entremove = Ent_RemoveProjectile;
339 void Projectile_Precache()
341 precache_model("models/ebomb.mdl");
342 precache_model("models/elaser.mdl");
343 precache_model("models/grenademodel.md3");
344 precache_model("models/hagarmissile.mdl");
345 precache_model("models/hlac_bullet.md3");
346 precache_model("models/laser.mdl");
347 precache_model("models/plasmatrail.mdl");
348 precache_model("models/rocket.md3");
349 precache_model("models/tracer.mdl");
350 precache_sound("weapons/electro_fly.wav");
351 precache_sound("weapons/rocket_fly.wav");
352 precache_sound("weapons/fireball_fly.wav");
353 precache_sound("weapons/fireball_fly2.wav");