2 // increments sprite frame, loops when end is hit.. simple
5 void (vector vec) WriteVec =
7 WriteCoord (MSG_BROADCAST, vec_x);
8 WriteCoord (MSG_BROADCAST, vec_y);
9 WriteCoord (MSG_BROADCAST, vec_z);
11 void (vector org, vector dir, float counts) W_Smoke =
13 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
14 WriteByte (MSG_BROADCAST, TE_SMOKE);
17 WriteByte (MSG_BROADCAST, counts);
20 // increments sprite frame, loops when end is hit.. simple
21 void animate_sprite (float startframe, float frame_count)
23 if ((self.frame - startframe) >= (frame_count - 1 ))
24 self.frame = startframe;
26 self.frame = self.frame + 1;
29 void W_UpdateAmmo (void)
32 self.items = self.items - (self.items & (IT_NAILS | IT_SHELLS | IT_ROCKETS | IT_CELLS));
34 if (self.weapon == IT_LASER)
36 else if (self.weapon == IT_SHOTGUN)
38 self.currentammo = self.ammo_shells;
39 self.items = self.items | IT_SHELLS;
41 else if (self.weapon == IT_UZI)
43 self.currentammo = self.ammo_nails;
44 self.items = self.items | IT_NAILS;
46 else if (self.weapon == IT_GRENADE_LAUNCHER || self.weapon == IT_HAGAR || self.weapon == IT_ROCKET_LAUNCHER)
48 self.currentammo = self.ammo_rockets;
49 self.items = self.items | IT_ROCKETS;
51 else if (self.weapon == IT_ELECTRO || self.weapon == IT_NEX || self.weapon == IT_CRYLINK)
53 self.currentammo = self.ammo_cells;
54 self.items = self.items | IT_CELLS;
59 void W_UpdateWeapon (void)
62 if (self.weapon == IT_LASER)
63 self.weaponmodel = "models/weapons/w_laser.zym";
64 else if (self.weapon == IT_SHOTGUN)
65 self.weaponmodel = "models/weapons/w_shotgun.zym";
66 else if (self.weapon == IT_UZI)
67 self.weaponmodel = "models/weapons/w_uzi.zym";
68 else if (self.weapon == IT_GRENADE_LAUNCHER)
69 self.weaponmodel = "models/weapons/w_gl.zym";
70 else if (self.weapon == IT_ELECTRO)
71 self.weaponmodel = "models/weapons/w_electro.zym";
72 else if (self.weapon == IT_CRYLINK)
73 self.weaponmodel = "models/weapons/w_crylink.zym";
74 else if (self.weapon == IT_NEX)
75 self.weaponmodel = "models/weapons/w_nex.zym";
76 else if (self.weapon == IT_HAGAR)
77 self.weaponmodel = "models/weapons/w_hagar.zym";
78 else if (self.weapon == IT_ROCKET_LAUNCHER)
79 self.weaponmodel = "models/weapons/w_rl.zym";
81 objerror ("Illegal weapon - please register your guns please!");
85 float W_GetBestWeapon (entity e)
88 if ((e.items & IT_ROCKET_LAUNCHER) && e.ammo_rockets)
89 return IT_ROCKET_LAUNCHER;
90 else if ((e.items & IT_NEX) && e.ammo_cells)
92 else if ((e.items & IT_HAGAR) && e.ammo_rockets)
94 else if ((e.items & IT_GRENADE_LAUNCHER) && e.ammo_rockets)
95 return IT_GRENADE_LAUNCHER;
96 else if ((e.items & IT_ELECTRO) && e.ammo_cells)
98 else if ((e.items & IT_CRYLINK) && e.ammo_cells)
100 else if ((e.items & IT_UZI) && e.ammo_nails)
102 else if ((e.items & IT_SHOTGUN) && e.ammo_shells)
110 void W_GiveWeapon (entity e, float wep)
117 e.items = e.items | wep;
122 weapon_action(self.weapon, WR_UPDATECOUNTS);
130 void W_SwitchWeapon (float wep)
133 var float noammo = FALSE;
139 nextwep = IT_SHOTGUN;
140 if (!self.ammo_shells)
146 if (!self.ammo_nails)
151 nextwep = IT_CRYLINK;
152 if (!self.ammo_cells)
157 nextwep = IT_ELECTRO;
158 if (!self.ammo_cells)
163 nextwep = IT_GRENADE_LAUNCHER;
164 if (!self.ammo_rockets)
170 if (!self.ammo_rockets)
176 if (!self.ammo_cells)
181 nextwep = IT_ROCKET_LAUNCHER;
182 if (!self.ammo_rockets)
187 if (!(self.items & nextwep))
189 sprint (self, "You don't own that weapon\n");
194 sprint (self, "You don't have any ammo for that weapon\n");
198 self.weapon = nextwep;
201 self.attack_finished = time + 0.2;
202 if (self.viewzoom != 1)
206 void W_NextWeapon (void)
214 if (self.weapon == IT_ROCKET_LAUNCHER)
215 self.weapon = IT_LASER;
216 else if (self.weapon == IT_LASER)
218 self.weapon = IT_SHOTGUN;
219 if (!self.ammo_shells)
222 else if (self.weapon == IT_SHOTGUN)
224 self.weapon = IT_UZI;
225 if (!self.ammo_nails)
228 else if (self.weapon == IT_UZI)
230 self.weapon = IT_CRYLINK;
231 if (!self.ammo_cells)
234 else if (self.weapon == IT_CRYLINK)
236 self.weapon = IT_ELECTRO;
237 if (!self.ammo_cells)
240 else if (self.weapon == IT_ELECTRO)
242 self.weapon = IT_GRENADE_LAUNCHER;
243 if (!self.ammo_cells)
246 else if (self.weapon == IT_GRENADE_LAUNCHER)
248 self.weapon = IT_HAGAR;
249 if (!self.ammo_rockets)
252 else if (self.weapon == IT_HAGAR)
254 self.weapon = IT_NEX;
255 if (!self.ammo_rockets)
258 else if (self.weapon == IT_NEX)
260 self.weapon = IT_ROCKET_LAUNCHER;
261 if (!self.ammo_cells)
265 if ((self.items & self.weapon) && !noammo)
274 void W_PreviousWeapon (void)
282 if (self.weapon == IT_SHOTGUN)
283 self.weapon = IT_LASER;
284 else if (self.weapon == IT_UZI)
286 self.weapon = IT_SHOTGUN;
287 if (!self.ammo_shells)
290 else if (self.weapon == IT_CRYLINK)
292 self.weapon = IT_UZI;
293 if (!self.ammo_nails)
296 else if (self.weapon == IT_ELECTRO)
298 self.weapon = IT_CRYLINK;
299 if (!self.ammo_cells)
302 else if (self.weapon == IT_GRENADE_LAUNCHER)
304 self.weapon = IT_ELECTRO;
305 if (!self.ammo_cells)
308 else if (self.weapon == IT_HAGAR)
310 self.weapon = IT_GRENADE_LAUNCHER;
311 if (!self.ammo_rockets)
314 else if (self.weapon == IT_NEX)
316 self.weapon = IT_HAGAR;
317 if (!self.ammo_rockets)
320 else if (self.weapon == IT_ROCKET_LAUNCHER)
322 self.weapon = IT_NEX;
323 if (!self.ammo_cells)
326 else if (self.weapon == IT_LASER)
328 self.weapon = IT_ROCKET_LAUNCHER;
329 if (!self.ammo_rockets)
333 if ((self.items & self.weapon) && !noammo)
342 float W_CheckAmmo (void)
344 if (game & (GAME_INSTAGIB | GAME_ROCKET_ARENA))
348 if (self.weapon == IT_LASER)
350 else if (self.currentammo)
353 self.weapon = W_GetBestWeapon (self);
360 void FireRailgunBullet (vector src, float bdamage, vector dir, float spread, float deathtype)
363 entity saveself, last;
365 org = self.origin + self.view_ofs;
374 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right * crandom () * spread + v_up * crandom () * spread, FALSE, self);
376 lastpos = trace_endpos;
377 if (trace_fraction != 1.0)
379 if (pointcontents(trace_endpos - dir*4) == CONTENT_SKY)
382 if (trace_ent.takedamage || trace_ent.classname == "case")
384 if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
385 te_blood (trace_endpos, dir * bdamage * 16, bdamage);
386 Damage (trace_ent, self, self, bdamage, deathtype, trace_endpos, dir * bdamage);
389 if (last.solid == SOLID_BSP)
394 void FireRailgunBullet (vector start, vector end, float damage, float dtype)
397 entity saveself, last;
399 org = self.origin + self.view_ofs;
408 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right * crandom () * spread + v_up * crandom () * spread, FALSE, self);
410 lastpos = trace_endpos;
411 if (trace_fraction != 1.0)
413 if (pointcontents(trace_endpos - dir*4) == CONTENT_SKY)
416 if (trace_ent.takedamage || trace_ent.classname == "case")
418 if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
419 te_blood (trace_endpos, dir * bdamage * 16, bdamage);
420 Damage (trace_ent, self, self, bdamage, deathtype, trace_endpos, dir * bdamage);
423 if (last.solid == SOLID_BSP)
428 void FireLaser (vector start, vector end, float damage, float dtype)
432 dir = normalize (end - start);
433 traceline_hitcorpse (self, start, end, FALSE, self);
435 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
436 WriteByte (MSG_BROADCAST, 76);
437 WriteCoord (MSG_BROADCAST, start_x);
438 WriteCoord (MSG_BROADCAST, start_y);
439 WriteCoord (MSG_BROADCAST, start_z);
440 WriteCoord (MSG_BROADCAST, trace_endpos_x);
441 WriteCoord (MSG_BROADCAST, trace_endpos_y);
442 WriteCoord (MSG_BROADCAST, trace_endpos_z);
443 WriteCoord (MSG_BROADCAST, 0);
444 WriteCoord (MSG_BROADCAST, 0);
445 WriteCoord (MSG_BROADCAST, 0);
447 if ((trace_fraction != 1.0) && (trace_ent != self) && (pointcontents (trace_endpos) != CONTENT_SKY))
449 if (trace_ent.classname == "case")
451 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
453 else if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
455 te_blood (trace_endpos, dir * damage * 16, damage);
456 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
462 void fireBullet (vector dir, float spread, float damage, float dtype)
467 // use traceline_hitcorpse to make sure it can hit gibs and corpses too
468 org = self.origin + self.view_ofs;
469 traceline_hitcorpse (self, org, org + v_forward * 4096 + v_right * crandom () * spread + v_up * crandom () * spread, FALSE, self);
471 // FIXME - causes excessive 'tinking'. Hopefully remove "tink1.wav" from the ricochets with csqc
472 if ((trace_fraction != 1.0) && (trace_ent != self) && (pointcontents (trace_endpos) != CONTENT_SKY))
474 if (trace_ent == world)
476 pointcontents (self.origin);
477 te_gunshot (trace_endpos);
480 sound (self, CHAN_IMPACT, "weapons/ric1.wav", 1, ATTN_NORM);
482 sound (self, CHAN_IMPACT, "weapons/ric2.wav", 1, ATTN_NORM);
484 sound (self, CHAN_IMPACT, "weapons/ric3.wav", 1, ATTN_NORM);
486 else if (trace_ent.classname == "case")
488 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
490 else if (trace_ent.classname == "player" || trace_ent.classname == "corpse" || trace_ent.classname == "gib")
492 te_blood (trace_endpos, dir * damage * 16, damage);
493 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * damage);
494 sound (trace_ent, CHAN_IMPACT, "misc/enemyimpact.wav", 1, ATTN_NORM);
502 if (self.deadflag != DEAD_NO)
504 if (self.death_time < time)
513 makevectors (self.v_angle);
514 //if (self.weapon == IT_LASER)
515 // W_Laser_Attack ();
516 //if (self.weapon == IT_SHOTGUN)
517 //W_Shotgun_Attack ();
518 //else if (self.weapon == IT_UZI)
520 if (self.weapon == IT_CRYLINK)
522 else if (self.weapon == IT_ELECTRO)
524 W_Electro_Attack (self.electrocount);
525 self.electrocount = self.electrocount + 1;
526 if (self.electrocount == 3)
527 self.electrocount = 0;
529 else if (self.weapon == IT_GRENADE_LAUNCHER)
531 else if (self.weapon == IT_HAGAR)
533 else if (self.weapon == IT_NEX)
535 //else if (self.weapon == IT_ROCKET_LAUNCHER)
536 // W_Rocket_Attack ();
541 void W_SecondaryAttack (void)
543 if (self.deadflag != DEAD_NO)
545 if (self.death_time < time)
554 makevectors (self.v_angle);
555 //if (self.weapon == IT_LASER)
556 //W_Laser_Attack2 ();
557 //if (self.weapon == IT_SHOTGUN)
558 //W_Shotgun_Attack2 ();
559 //else if (self.weapon == IT_UZI)
561 else if (self.weapon == IT_CRYLINK)
562 W_Crylink_Attack2 ();
563 else if (self.weapon == IT_ELECTRO) {
564 W_Electro_Attack2 (self.electrocount);
565 self.electrocount = self.electrocount + 1;
566 if (self.electrocount == 3)
567 self.electrocount = 0;
569 else if (self.weapon == IT_GRENADE_LAUNCHER)
570 W_Grenade_Attack2 ();
571 else if (self.weapon == IT_HAGAR)
573 else if (self.weapon == IT_NEX)
575 //else if (self.weapon == IT_ROCKET_LAUNCHER)
576 //W_Rocket_Attack2 ();
581 void W_ThirdAttack (void)
583 if (self.deadflag != DEAD_NO)
585 if (self.death_time < time)
594 makevectors (self.v_angle);
595 //if (self.weapon == IT_LASER)
596 //W_Laser_Attack2 ();
597 //if (self.weapon == IT_SHOTGUN)
598 //W_Shotgun_Attack2 ();
599 //else if (self.weapon == IT_UZI)
601 else if (self.weapon == IT_CRYLINK)
602 W_Crylink_Attack2 ();
603 else if (self.weapon == IT_ELECTRO) {
604 W_Electro_Attack3 (self.electrocount);
605 self.electrocount = self.electrocount + 1;
606 if (self.electrocount == 3)
607 self.electrocount = 0;
609 else if (self.weapon == IT_GRENADE_LAUNCHER)
610 W_Grenade_Attack3 ();
611 else if (self.weapon == IT_HAGAR)
613 else if (self.weapon == IT_NEX)
615 //else if (self.weapon == IT_ROCKET_LAUNCHER)
616 //W_Rocket_Attack3 ();