home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / xtrawp19 / weapons.qc < prev    next >
Encoding:
Text File  |  1996-08-09  |  31.4 KB  |  1,504 lines

  1. /*
  2. */
  3. void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  4. void () player_run;
  5. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  6. void(vector org, vector vel, float damage) SpawnBlood;
  7. void() SuperDamageSound;
  8.  
  9.  
  10. // called by worldspawn
  11. void() W_Precache =
  12. {
  13.     precache_sound ("weapons/r_exp3.wav");  // new rocket explosion
  14.     precache_sound ("weapons/rocket1i.wav");  // spike gun
  15.     precache_sound ("weapons/sgun1.wav");
  16.     precache_sound ("weapons/guncock.wav"); // player shotgun
  17.     precache_sound ("weapons/ric1.wav");  // ricochet (used in c code)
  18.     precache_sound ("weapons/ric2.wav");  // ricochet (used in c code)
  19.     precache_sound ("weapons/ric3.wav");  // ricochet (used in c code)
  20.     precache_sound ("weapons/spike2.wav");  // super spikes
  21.     precache_sound ("weapons/tink1.wav"); // spikes tink (used in c code)
  22.     precache_sound ("weapons/grenade.wav"); // grenade launcher
  23.     precache_sound ("weapons/bounce.wav");    // grenade bounce
  24.     precache_sound ("weapons/shotgn2.wav"); // super shotgun
  25.     precache_model2 ("progs/laser.mdl");
  26.     precache_sound2 ("enforcer/enfire.wav");
  27.     precache_sound2 ("enforcer/enfstop.wav");    
  28.     precache_model2 ("progs/flame2.mdl");
  29.     precache_sound2 ("ambience/fire1.wav");
  30. };
  31.  
  32. float() crandom =
  33. {
  34.     return 2*(random() - 0.5);
  35. };
  36.  
  37. /*
  38. ================
  39. W_FireAxe
  40. ================
  41. */
  42. void() W_FireAxe =
  43. {
  44.     local vector  source;
  45.     local vector  org;
  46.  
  47.     source = self.origin + '0 0 16';
  48.     traceline (source, source + v_forward*64, FALSE, self);
  49.     if (trace_fraction == 1.0)
  50.         return;
  51.     
  52.     org = trace_endpos - v_forward*4;
  53.  
  54.     if (trace_ent.takedamage)
  55.     {
  56.         trace_ent.axhitme = 1;
  57.         SpawnBlood (org, '0 0 0', 20);
  58.         T_Damage (trace_ent, self, self, 20);
  59.     }
  60.     else
  61.     { // hit wall
  62.         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  63.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  64.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  65.         WriteCoord (MSG_BROADCAST, org_x);
  66.         WriteCoord (MSG_BROADCAST, org_y);
  67.         WriteCoord (MSG_BROADCAST, org_z);
  68.     }
  69. };
  70.  
  71.  
  72. //============================================================================
  73.  
  74.  
  75. vector() wall_velocity =
  76. {
  77.     local vector  vel;
  78.     
  79.     vel = normalize (self.velocity);
  80.     vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  81.     vel = vel + 2*trace_plane_normal;
  82.     vel = vel * 200;
  83.     
  84.     return vel;
  85. };
  86.  
  87.  
  88. /*
  89. ================
  90. SpawnMeatSpray
  91. ================
  92. */
  93. void(vector org, vector vel) SpawnMeatSpray =
  94. {
  95.     local entity missile, mpuff;
  96.     local vector  org;
  97.  
  98.     missile = spawn ();
  99.     missile.owner = self;
  100.     missile.movetype = MOVETYPE_BOUNCE;
  101.     missile.solid = SOLID_NOT;
  102.  
  103.     makevectors (self.angles);
  104.  
  105.     missile.velocity = vel;
  106.     missile.velocity_z = missile.velocity_z + 250 + 50*random();
  107.  
  108.     missile.avelocity = '3000 1000 2000';
  109.     
  110. // set missile duration
  111.     missile.nextthink = time + 1;
  112.     missile.think = SUB_Remove;
  113.  
  114.     setmodel (missile, "progs/zom_gib.mdl");
  115.     setsize (missile, '0 0 0', '0 0 0');    
  116.     setorigin (missile, org);
  117. };
  118.  
  119. /*
  120. ================
  121. SpawnBlood
  122. ================
  123. */
  124. void(vector org, vector vel, float damage) SpawnBlood =
  125. {
  126.     particle (org, vel*0.1, 73, damage*2);
  127. };
  128.  
  129. /*
  130. ================
  131. spawn_touchblood
  132. ================
  133. */
  134. void(float damage) spawn_touchblood =
  135. {
  136.     local vector  vel;
  137.  
  138.     vel = wall_velocity () * 0.2;
  139.     SpawnBlood (self.origin + vel*0.01, vel, damage);
  140. };
  141.  
  142.  
  143. /*
  144. ================
  145. SpawnChunk
  146. ================
  147. */
  148. void(vector org, vector vel) SpawnChunk =
  149. {
  150.     particle (org, vel*0.02, 0, 10);
  151. };
  152.  
  153. /*
  154. ==============================================================================
  155.  
  156. MULTI-DAMAGE
  157.  
  158. Collects multiple small damages into a single damage
  159.  
  160. ==============================================================================
  161. */
  162.  
  163. entity  multi_ent;
  164. float multi_damage;
  165.  
  166. void() ClearMultiDamage =
  167. {
  168.     multi_ent = world;
  169.     multi_damage = 0;
  170. };
  171.  
  172. void() ApplyMultiDamage =
  173. {
  174.     if (!multi_ent)
  175.         return;
  176.     T_Damage (multi_ent, self, self, multi_damage);
  177. };
  178.  
  179. void(entity hit, float damage) AddMultiDamage =
  180. {
  181.     if (!hit)
  182.         return;
  183.     
  184.     if (hit != multi_ent)
  185.     {
  186.         ApplyMultiDamage ();
  187.         multi_damage = damage;
  188.         multi_ent = hit;
  189.     }
  190.     else
  191.         multi_damage = multi_damage + damage;
  192. };
  193.  
  194. /*
  195. ==============================================================================
  196.  
  197. BULLETS
  198.  
  199. ==============================================================================
  200. */
  201.  
  202. /*
  203. ================
  204. TraceAttack
  205. ================
  206. */
  207. void(float damage, vector dir) TraceAttack =
  208. {
  209.     local vector  vel, org;
  210.     
  211.     vel = normalize(dir + v_up*crandom() + v_right*crandom());
  212.     vel = vel + 2*trace_plane_normal;
  213.     vel = vel * 200;
  214.  
  215.     org = trace_endpos - dir*4;
  216.  
  217.     if (trace_ent.takedamage)
  218.     {
  219.         SpawnBlood (org, vel*0.2, damage);
  220.         AddMultiDamage (trace_ent, damage);
  221.     }
  222.     else
  223.     {
  224.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  225.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  226.         WriteCoord (MSG_BROADCAST, org_x);
  227.         WriteCoord (MSG_BROADCAST, org_y);
  228.         WriteCoord (MSG_BROADCAST, org_z);
  229.     }
  230. };
  231.  
  232. /*
  233. ================
  234. FireBullets
  235.  
  236. Used by shotgun, super shotgun, and enemy soldier firing
  237. Go to the trouble of combining multiple pellets into a single damage call.
  238. ================
  239. */
  240. void(float shotcount, vector dir, vector spread) FireBullets =
  241. {
  242.     local vector direction;
  243.     local vector  src;
  244.     
  245.     makevectors(self.v_angle);
  246.  
  247.     src = self.origin + v_forward*10;
  248.     src_z = self.absmin_z + self.size_z * 0.7;
  249.  
  250.     ClearMultiDamage ();
  251.     while (shotcount > 0)
  252.     {
  253.         direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  254.  
  255.         traceline (src, src + direction*2048, FALSE, self);
  256.         if (trace_fraction != 1.0)
  257.             TraceAttack (4, direction);
  258.  
  259.         shotcount = shotcount - 1;
  260.     }
  261.     ApplyMultiDamage ();
  262. };
  263.  
  264. /*
  265. ================
  266. W_FireShotgun
  267. ================
  268. */
  269. void() W_FireShotgun =
  270. {
  271.     local vector dir;
  272.  
  273.     sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM); 
  274.  
  275.     self.punchangle_x = -2;
  276.     
  277.     self.currentammo = self.ammo_shells = self.ammo_shells - 1;
  278.     dir = aim (self, 100000);
  279.     FireBullets (6, dir, '0.04 0.04 0');
  280. };
  281.  
  282.  
  283. /*
  284. ================
  285. W_FireSuperShotgun
  286. ================
  287. */
  288. void() W_FireSuperShotgun =
  289. {
  290.     local vector dir;
  291.  
  292.     if (self.currentammo == 1)
  293.     {
  294.         W_FireShotgun ();
  295.         return;
  296.     }
  297.         
  298.     sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM); 
  299.  
  300.     self.punchangle_x = -4;
  301.     
  302.     self.currentammo = self.ammo_shells = self.ammo_shells - 2;
  303.     dir = aim (self, 100000);
  304.     FireBullets (21, dir, '0.14 0.08 0');
  305. };
  306.  
  307.  
  308. /*
  309. ==============================================================================
  310.  
  311. ROCKETS
  312.  
  313. ==============================================================================
  314. */
  315.  
  316. void()  s_explode1  = [0,   s_explode2] {};
  317. void()  s_explode2  = [1,   s_explode3] {};
  318. void()  s_explode3  = [2,   s_explode4] {};
  319. void()  s_explode4  = [3,   s_explode5] {};
  320. void()  s_explode5  = [4,   s_explode6] {};
  321. void()  s_explode6  = [5,   SUB_Remove] {};
  322.  
  323. void() BecomeExplosion =
  324. {
  325.     self.movetype = MOVETYPE_NONE;
  326.     self.velocity = '0 0 0';
  327.     self.touch = SUB_Null;
  328.     setmodel (self, "progs/s_explod.spr");
  329.     self.solid = SOLID_NOT;
  330.     s_explode1 ();
  331. };
  332.  
  333. void() T_MissileTouch =
  334. {
  335.     local float damg;
  336.  
  337.     if (other == self.owner)
  338.         return;   // don't explode on owner
  339.  
  340.     if (pointcontents(self.origin) == CONTENT_SKY)
  341.     {
  342.         remove(self);
  343.         return;
  344.     }
  345.  
  346.     damg = 40 + random()*20;
  347.     
  348.     if (other.health)
  349.     {
  350.         if (other.classname == "monster_shambler")
  351.             damg = damg * 0.5;  // mostly immune
  352.         T_Damage (other, self, self.owner, damg );
  353.     }
  354.  
  355.     // don't do radius damage to the other, because all the damage
  356.     // was done in the impact
  357.     T_RadiusDamage (self, self.owner, 50, other);
  358.  
  359. //  sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
  360.     self.origin = self.origin - 8*normalize(self.velocity);
  361.  
  362.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  363.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  364.     WriteCoord (MSG_BROADCAST, self.origin_x);
  365.     WriteCoord (MSG_BROADCAST, self.origin_y);
  366.     WriteCoord (MSG_BROADCAST, self.origin_z);
  367.  
  368.     BecomeExplosion ();
  369. };
  370.  
  371.  
  372.  
  373. /*
  374. ================
  375. W_FireRocket
  376. ================
  377. */
  378. void() W_FireRocket =
  379. {
  380.     local entity missile, mpuff;
  381.     
  382.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  383.     
  384.     sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  385.  
  386.     self.punchangle_x = -2;
  387.  
  388.     missile = spawn ();
  389.     missile.owner = self;
  390.     missile.movetype = MOVETYPE_FLYMISSILE;
  391.     missile.solid = SOLID_BBOX;
  392.         
  393. // set missile speed  
  394.  
  395.     makevectors (self.v_angle);
  396.     missile.velocity = aim(self, 1000);
  397.     missile.velocity = missile.velocity * 1000;
  398.     missile.angles = vectoangles(missile.velocity);
  399.     
  400.     missile.touch = T_MissileTouch;
  401.     
  402. // set missile duration
  403.     missile.nextthink = time + 5;
  404.     missile.think = SUB_Remove;
  405.  
  406.     setmodel (missile, "progs/missile.mdl");
  407.     setsize (missile, '0 0 0', '0 0 0');    
  408.     setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  409. };
  410.  
  411. /*
  412. ===============================================================================
  413.  
  414. LIGHTNING
  415.  
  416. ===============================================================================
  417. */
  418.  
  419. /*
  420. =================
  421. LightningDamage
  422. =================
  423. */
  424. void(vector p1, vector p2, entity from, float damage) LightningDamage =
  425. {
  426.     local entity    e1, e2;
  427.     local vector    f;
  428.     
  429.     f = p2 - p1;
  430.     normalize (f);
  431.     f_x = 0 - f_y;
  432.     f_y = f_x;
  433.     f_z = 0;
  434.     f = f*16;
  435.  
  436.     e1 = e2 = world;
  437.  
  438.     traceline (p1, p2, FALSE, self);
  439.     if (trace_ent.takedamage)
  440.     {
  441.         particle (trace_endpos, '0 0 100', 225, damage*4);
  442.         T_Damage (trace_ent, from, from, damage);
  443.         if (self.classname == "player")
  444.         {
  445.             if (other.classname == "player")
  446.                 trace_ent.velocity_z = trace_ent.velocity_z + 400;
  447.         }
  448.     }
  449.     e1 = trace_ent;
  450.  
  451.     traceline (p1 + f, p2 + f, FALSE, self);
  452.     if (trace_ent != e1 && trace_ent.takedamage)
  453.     {
  454.         particle (trace_endpos, '0 0 100', 225, damage*4);
  455.         T_Damage (trace_ent, from, from, damage);
  456.     }
  457.     e2 = trace_ent;
  458.  
  459.     traceline (p1 - f, p2 - f, FALSE, self);
  460.     if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
  461.     {
  462.         particle (trace_endpos, '0 0 100', 225, damage*4);
  463.         T_Damage (trace_ent, from, from, damage);
  464.     }
  465. };
  466.  
  467.  
  468. void() W_FireLightning =
  469. {
  470.     local vector    org;
  471.  
  472.     if (self.ammo_cells < 1)
  473.     {
  474.         self.weapon = W_BestWeapon ();
  475.         W_SetCurrentAmmo ();
  476.         return;
  477.     }
  478.  
  479. // explode if under water
  480.     if (self.waterlevel > 1)
  481.     {
  482.         T_RadiusDamage (self, self, 35*self.ammo_cells, world);
  483.         self.ammo_cells = 0;
  484.         W_SetCurrentAmmo ();
  485.         return;
  486.     }
  487.  
  488.     if (self.t_width < time)
  489.     {
  490.         sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  491.         self.t_width = time + 0.6;
  492.     }
  493.     self.punchangle_x = -2;
  494.  
  495.     self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  496.  
  497.     org = self.origin + '0 0 16';
  498.     
  499.     traceline (org, org + v_forward*600, TRUE, self);
  500.  
  501.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  502.     WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  503.     WriteEntity (MSG_BROADCAST, self);
  504.     WriteCoord (MSG_BROADCAST, org_x);
  505.     WriteCoord (MSG_BROADCAST, org_y);
  506.     WriteCoord (MSG_BROADCAST, org_z);
  507.     WriteCoord (MSG_BROADCAST, trace_endpos_x);
  508.     WriteCoord (MSG_BROADCAST, trace_endpos_y);
  509.     WriteCoord (MSG_BROADCAST, trace_endpos_z);
  510.  
  511.     LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
  512. };
  513.  
  514.  
  515. //=============================================================================
  516.  
  517. void() GrenadeExplode =
  518. {
  519.     T_RadiusDamage (self, self.owner, 60, world);
  520.  
  521.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  522.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  523.     WriteCoord (MSG_BROADCAST, self.origin_x);
  524.     WriteCoord (MSG_BROADCAST, self.origin_y);
  525.     WriteCoord (MSG_BROADCAST, self.origin_z);
  526.  
  527.     BecomeExplosion ();
  528. };
  529.  
  530. void() GrenadeTouch =
  531. {
  532.     if (other == self.owner)
  533.         return;   // don't explode on owner
  534.     if (other.takedamage == DAMAGE_AIM)
  535.     {
  536.         GrenadeExplode();
  537.         return;
  538.     }
  539.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);  // bounce sound
  540.     if (self.velocity == '0 0 0')
  541.         self.avelocity = '0 0 0';
  542. };
  543.  
  544. /*
  545. ================
  546. W_FireGrenade
  547. ================
  548. */
  549. void() W_FireGrenade =
  550. {
  551.     local entity missile, mpuff;
  552.     
  553.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  554.     
  555.     sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  556.  
  557.     self.punchangle_x = -2;
  558.  
  559.     missile = spawn ();
  560.     missile.owner = self;
  561.     missile.movetype = MOVETYPE_BOUNCE;
  562.     missile.solid = SOLID_BBOX;
  563.     missile.classname = "grenade";
  564.         
  565. // set missile speed  
  566.  
  567.     makevectors (self.v_angle);
  568.  
  569.     if (self.v_angle_x)
  570.         missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  571.     else
  572.     {
  573.         missile.velocity = aim(self, 10000);
  574.         missile.velocity = missile.velocity * 600;
  575.         missile.velocity_z = 200;
  576.     }
  577.  
  578.     missile.avelocity = '300 300 300';
  579.  
  580.     missile.angles = vectoangles(missile.velocity);
  581.     
  582.     missile.touch = GrenadeTouch;
  583.     
  584. // set missile duration
  585.     missile.nextthink = time + 2.5;
  586.     missile.think = GrenadeExplode;
  587.  
  588.     setmodel (missile, "progs/grenade.mdl");
  589.     setsize (missile, '0 0 0', '0 0 0');    
  590.     setorigin (missile, self.origin);
  591. };
  592.  
  593. //=============================================================================
  594.  
  595. void() spike_touch;
  596. void() superspike_touch;
  597.  
  598.  
  599. /*
  600. ===============
  601. launch_spike
  602.  
  603. Used for both the player and the ogre
  604. ===============
  605. */
  606. void(vector org, vector dir) launch_spike =
  607. {
  608.     newmis = spawn ();
  609.     newmis.owner = self;
  610.     newmis.movetype = MOVETYPE_FLYMISSILE;
  611.     newmis.solid = SOLID_BBOX;
  612.  
  613.     newmis.angles = vectoangles(dir);
  614.     
  615.     newmis.touch = spike_touch;
  616.     newmis.classname = "spike";
  617.     newmis.think = SUB_Remove;
  618.     newmis.nextthink = time + 6;
  619.     setmodel (newmis, "progs/spike.mdl");
  620.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);   
  621.     setorigin (newmis, org);
  622.     
  623.     newmis.velocity = dir * 1000;
  624. };
  625.  
  626. void() W_FireSuperSpikes =
  627. {
  628.     local vector  dir;
  629.     local entity  old;
  630.     
  631.     sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  632.     self.attack_finished = time + 0.2;
  633.     self.currentammo = self.ammo_nails = self.ammo_nails - 2;
  634.     dir = aim (self, 1000);
  635.     launch_spike (self.origin + '0 0 16', dir);
  636.     newmis.touch = superspike_touch;
  637.     setmodel (newmis, "progs/s_spike.mdl");
  638.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);   
  639.     self.punchangle_x = -2;
  640. };
  641.  
  642. void(float ox) W_FireSpikes =
  643. {
  644.     local vector  dir;
  645.     local entity  old;
  646.     
  647.     makevectors (self.v_angle);
  648.     
  649.     if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
  650.     {
  651.         W_FireSuperSpikes ();
  652.         return;
  653.     }
  654.  
  655.     if (self.ammo_nails < 1)
  656.     {
  657.         self.weapon = W_BestWeapon ();
  658.         W_SetCurrentAmmo ();
  659.         return;
  660.     }
  661.  
  662.     sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
  663.     self.attack_finished = time + 0.2;
  664.     self.currentammo = self.ammo_nails = self.ammo_nails - 1;
  665.     dir = aim (self, 1000);
  666.     launch_spike (self.origin + '0 0 16' + v_right*ox, dir);
  667.  
  668.     self.punchangle_x = -2;
  669. };
  670.  
  671.  
  672.  
  673. .float hit_z;
  674. void() spike_touch =
  675. {
  676. local float rand;
  677.     if (other == self.owner)
  678.         return;
  679.  
  680.     if (other.solid == SOLID_TRIGGER)
  681.         return; // trigger field, do nothing
  682.  
  683.     if (pointcontents(self.origin) == CONTENT_SKY)
  684.     {
  685.         remove(self);
  686.         return;
  687.     }
  688.     
  689. // hit something that bleeds
  690.     if (other.takedamage)
  691.     {
  692.         spawn_touchblood (9);
  693.         T_Damage (other, self, self.owner, 9);
  694.     }
  695.     else
  696.     {
  697.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  698.         
  699.         if (self.classname == "wizspike")
  700.             WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  701.         else if (self.classname == "knightspike")
  702.             WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  703.         else
  704.             WriteByte (MSG_BROADCAST, TE_SPIKE);
  705.         WriteCoord (MSG_BROADCAST, self.origin_x);
  706.         WriteCoord (MSG_BROADCAST, self.origin_y);
  707.         WriteCoord (MSG_BROADCAST, self.origin_z);
  708.     }
  709.  
  710.     remove(self);
  711.  
  712. };
  713.  
  714. void() superspike_touch =
  715. {
  716. local float rand;
  717.     if (other == self.owner)
  718.         return;
  719.  
  720.     if (other.solid == SOLID_TRIGGER)
  721.         return; // trigger field, do nothing
  722.  
  723.     if (pointcontents(self.origin) == CONTENT_SKY)
  724.     {
  725.         remove(self);
  726.         return;
  727.     }
  728.     
  729. // hit something that bleeds
  730.     if (other.takedamage)
  731.     {
  732.         spawn_touchblood (18);
  733.         T_Damage (other, self, self.owner, 18);
  734.     }
  735.     else
  736.     {
  737.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  738.         WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
  739.         WriteCoord (MSG_BROADCAST, self.origin_x);
  740.         WriteCoord (MSG_BROADCAST, self.origin_y);
  741.         WriteCoord (MSG_BROADCAST, self.origin_z);
  742.     }
  743.  
  744.     remove(self);
  745.  
  746. };
  747.  
  748.  
  749. /*
  750. ===============================================================================
  751.  
  752. PLAYER WEAPON USE
  753.  
  754. ===============================================================================
  755. */
  756.  
  757. void() W_SetCurrentAmmo =
  758. {
  759.     local float tmp;
  760.     player_run ();    // get out of any weapon firing states
  761.  
  762.     self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
  763.     if (self.ef&EXTRA_1) 
  764.     {
  765.         if (self.weapon == WP_CLUSTER)
  766.         {
  767.             self.currentammo = floor(self.ammo_rockets/10);
  768.             self.weaponmodel = "progs/v_rock.mdl";
  769.             self.weaponframe = 0;
  770.             self.items = self.items | IT_ROCKETS;
  771.         }
  772.         else if (self.weapon == WP_BOUNCER)
  773.         {
  774.             self.weaponmodel = "progs/v_rock.mdl";
  775.             self.items = self.items | IT_ROCKETS | IT_NAILS;
  776.             tmp=floor(self.ammo_nails/20);
  777.             self.currentammo = min(self.ammo_rockets,tmp);
  778.         }
  779.         else if (self.weapon == WP_FRAGROCK)
  780.         {
  781.             self.weaponmodel = "progs/v_rock2.mdl";
  782.             self.items=self.items | IT_ROCKETS | IT_NAILS;
  783.             tmp=floor(self.ammo_nails/20);
  784.             self.currentammo = min(self.ammo_rockets,tmp);
  785.         }
  786.         else if (self.weapon == WP_LASER)
  787.         {
  788.             self.weaponmodel = "progs/v_shot.mdl";
  789.             self.items=self.items | IT_CELLS;
  790.             self.currentammo = floor(self.ammo_cells/4);
  791.         }
  792.         else if (self.weapon == WP_HOMER)
  793.         {
  794.             self.weaponmodel = "progs/v_rock2.mdl";
  795.             self.items=self.items | IT_ROCKETS;
  796.             self.currentammo=floor(self.ammo_rockets/5);
  797.         }
  798.         else if (self.weapon == WP_PHOSPHOR)
  799.         {
  800.             self.weaponmodel = "progs/v_rock.mdl";
  801.             self.items=self.items | IT_ROCKETS;
  802.             self.currentammo=floor(self.ammo_rockets/10);
  803.         }
  804.         else if (self.weapon == WP_LIGHTROCK)
  805.         {
  806.             self.weaponmodel = "progs/v_rock2.mdl";
  807.             self.items=self.items | IT_ROCKETS | IT_CELLS;
  808.             tmp=floor(self.ammo_cells/40);
  809.             self.currentammo=min(self.ammo_rockets,tmp);
  810.         }
  811.         else if (self.weapon == WP_NAPALMROCK)
  812.         {
  813.             self.weaponmodel = "progs/v_rock2.mdl";
  814.             self.items=self.items | IT_ROCKETS | IT_NAPALM;
  815.             tmp=floor(self.ammo_napalm/10);
  816.             self.currentammo=min(self.ammo_rockets,tmp);
  817.         }
  818.         else if (self.weapon == WP_NAPALMGREN)
  819.         {
  820.             self.weaponmodel = "progs/v_rock.mdl";
  821.             self.items=self.items | IT_ROCKETS | IT_NAPALM;
  822.             tmp=floor(self.ammo_napalm/25);
  823.             self.currentammo=min(self.ammo_rockets,tmp);
  824.         }
  825.     }
  826.     else
  827.     {
  828.         if (self.weapon == IT_AXE)
  829.         {
  830.             self.currentammo = 0;
  831.             self.weaponmodel = "progs/v_axe.mdl";
  832.             self.weaponframe = 0;
  833.         }
  834.         else if (self.weapon == IT_SHOTGUN)
  835.         {
  836.             self.currentammo = self.ammo_shells;
  837.             self.weaponmodel = "progs/v_shot.mdl";
  838.             self.weaponframe = 0;
  839.             self.items = self.items | IT_SHELLS;
  840.         }
  841.         else if (self.weapon == IT_SUPER_SHOTGUN)
  842.         {
  843.             self.currentammo = self.ammo_shells;
  844.             self.weaponmodel = "progs/v_shot2.mdl";
  845.             self.weaponframe = 0;
  846.             self.items = self.items | IT_SHELLS;
  847.         }
  848.         else if (self.weapon == IT_NAILGUN)
  849.         {
  850.             self.currentammo = self.ammo_nails;
  851.             self.weaponmodel = "progs/v_nail.mdl";
  852.             self.weaponframe = 0;
  853.             self.items = self.items | IT_NAILS;
  854.         }
  855.         else if (self.weapon == IT_SUPER_NAILGUN)
  856.         {
  857.             self.currentammo = self.ammo_nails;
  858.             self.weaponmodel = "progs/v_nail2.mdl";
  859.             self.weaponframe = 0;
  860.             self.items = self.items | IT_NAILS;
  861.         }
  862.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  863.         {
  864.             self.currentammo = self.ammo_rockets;
  865.             self.weaponmodel = "progs/v_rock.mdl";
  866.             self.weaponframe = 0;
  867.             self.items = self.items | IT_ROCKETS;
  868.         }
  869.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  870.         {
  871.             self.currentammo = self.ammo_rockets;
  872.             self.weaponmodel = "progs/v_rock2.mdl";
  873.             self.weaponframe = 0;
  874.             self.items = self.items | IT_ROCKETS;
  875.         }
  876.         else if (self.weapon == IT_LIGHTNING)
  877.         {
  878.             self.currentammo = self.ammo_cells;
  879.             self.weaponmodel = "progs/v_light.mdl";
  880.             self.weaponframe = 0;
  881.             self.items = self.items | IT_CELLS;
  882.         }
  883.         else
  884.         {
  885.             self.currentammo = 0;
  886.             self.weaponmodel = "";
  887.             self.weaponframe = 0;
  888.         }
  889.     }
  890. };
  891.  
  892. float() W_BestWeapon =
  893. {
  894.     local float it;
  895.     
  896.     it = self.items;
  897.  
  898.     if(self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
  899.         return IT_LIGHTNING;
  900.     else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
  901.         return IT_SUPER_NAILGUN;
  902.     else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
  903.         return IT_SUPER_SHOTGUN;
  904.     else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
  905.         return IT_NAILGUN;
  906.     else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
  907.         return IT_SHOTGUN;
  908.         
  909. /*
  910.     if(self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER) )
  911.         return IT_ROCKET_LAUNCHER;
  912.     else if(self.ammo_rockets >= 1 && (it & IT_GRENADE_LAUNCHER) )
  913.         return IT_GRENADE_LAUNCHER;
  914.  
  915. */
  916.  
  917.     return IT_AXE;
  918. };
  919.  
  920. float() W_CheckNoAmmo =
  921. {
  922.     if (self.currentammo > 0)
  923.         return TRUE;
  924.  
  925.     if (self.weapon == IT_AXE)
  926.         return TRUE;
  927.  
  928.     self.weapon = W_BestWeapon ();
  929.  
  930.     W_SetCurrentAmmo ();
  931.     
  932. // drop the weapon down
  933.     return FALSE;
  934. };
  935.  
  936. /*
  937. ============
  938. W_Attack
  939.  
  940. An attack impulse can be triggered now
  941. ============
  942. */
  943. void()  player_axe1;
  944. void()  player_axeb1;
  945. void()  player_axec1;
  946. void()  player_axed1;
  947. void()  player_shot1;
  948. void()  player_nail1;
  949. void()  player_light1;
  950. void()  player_rocket1;
  951.  
  952. void() W_Attack =
  953. {
  954.     local float r;
  955.  
  956.     if (!W_CheckNoAmmo ())
  957.         return;
  958.  
  959.     makevectors (self.v_angle);     // calculate forward angle for velocity
  960.     self.show_hostile = time + 1; // wake monsters up
  961.     
  962.     if (self.ef&EXTRA_1) 
  963.     {
  964.         if (self.weapon == WP_CLUSTER)
  965.         {
  966.             player_rocket1();
  967.             W_FireCluster();
  968.             self.attack_finished = time + 0.6;
  969.         }
  970.         else if (self.weapon == WP_BOUNCER)
  971.         {
  972.             player_rocket1();
  973.             W_FireBouncer();
  974.             self.attack_finished = time + 0.6;
  975.         }
  976.         else if (self.weapon == WP_FRAGROCK)
  977.         {
  978.             player_rocket1();
  979.             W_FireShotRock();
  980.             self.attack_finished=time+0.8;
  981.         }
  982.         else if (self.weapon == WP_LASER)
  983.         {
  984.             player_shot1();
  985.             W_FireLaser();
  986.             self.attack_finished=time+0.5;
  987.         }
  988.         else if (self.weapon == WP_HOMER)
  989.         {
  990.             player_rocket1();
  991.             FireHomingMissile();
  992.             self.attack_finished=time+0.8;
  993.         }
  994.         else if (self.weapon == WP_PHOSPHOR)
  995.         {
  996.             player_rocket1();
  997.             W_FirePhosphor();
  998.             self.attack_finished=time+0.6;
  999.         }
  1000.         else if (self.weapon == WP_LIGHTROCK)
  1001.         {
  1002.             player_rocket1();
  1003.             W_FireLightRocket();
  1004.             self.attack_finished=time+0.8;
  1005.         }
  1006.         else if (self.weapon == WP_NAPALMROCK)
  1007.         {
  1008.             player_rocket1();
  1009.             W_FireNapalmRocket();
  1010.             self.attack_finished=time+0.8;
  1011.         }
  1012.         else if (self.weapon == WP_NAPALMGREN)
  1013.         {
  1014.             player_rocket1();
  1015.             W_FireNapalmGrenade();
  1016.             self.attack_finished=time+0.8;
  1017.         }
  1018.     }
  1019.     else
  1020.     {
  1021.         if (self.weapon == IT_AXE)
  1022.         {
  1023.             sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1024.             r = random();
  1025.             if (r < 0.25)
  1026.                 player_axe1 ();
  1027.             else if (r<0.5)
  1028.                 player_axeb1 ();
  1029.             else if (r<0.75)
  1030.                 player_axec1 ();
  1031.             else
  1032.                 player_axed1 ();
  1033.             self.attack_finished = time + 0.5;
  1034.         }
  1035.         else if (self.weapon == IT_SHOTGUN)
  1036.         {
  1037.             player_shot1 ();
  1038.             W_FireShotgun ();
  1039.             self.attack_finished = time + 0.5;
  1040.         }
  1041.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1042.         {
  1043.             player_shot1 ();
  1044.             W_FireSuperShotgun ();
  1045.             self.attack_finished = time + 0.7;
  1046.         }
  1047.         else if (self.weapon == IT_NAILGUN)
  1048.         {
  1049.             player_nail1 ();
  1050.         }
  1051.         else if (self.weapon == IT_SUPER_NAILGUN)
  1052.         {
  1053.             player_nail1 ();
  1054.         }
  1055.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  1056.         {
  1057.             player_rocket1();
  1058.             W_FireGrenade();
  1059.             self.attack_finished = time + 0.6;
  1060.         }
  1061.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1062.         {
  1063.             player_rocket1();
  1064.             W_FireRocket();
  1065.             self.attack_finished = time + 0.8;
  1066.         }
  1067.         else if (self.weapon == IT_LIGHTNING)
  1068.         {
  1069.             player_light1();
  1070.             self.attack_finished = time + 0.1;
  1071.             sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  1072.         }
  1073.     }
  1074. };    
  1075.  
  1076. /*
  1077. ============
  1078. W_ChangeWeapon
  1079.  
  1080. ============
  1081. */
  1082. void() W_ChangeWeapon =
  1083. {
  1084.     local float it, am, fl, extra;
  1085.     
  1086.     it = self.items;
  1087.     am = 0;
  1088.  
  1089.     if (self.impulse == 1)
  1090.     {
  1091.         fl = IT_AXE;
  1092.         extra=0;        
  1093.     }
  1094.     else if (self.impulse == 2)
  1095.     {
  1096.         fl = IT_SHOTGUN;
  1097.         extra=0;        
  1098.         if (self.ammo_shells < 1)
  1099.             am = 1;
  1100.     }
  1101.     else if (self.impulse == 3)
  1102.     {
  1103.         fl = IT_SUPER_SHOTGUN;
  1104.         extra=0;        
  1105.         if (self.ammo_shells < 2)
  1106.             am = 1;
  1107.     }   
  1108.     else if (self.impulse == 4)
  1109.     {
  1110.         fl = IT_NAILGUN;
  1111.         extra=0;        
  1112.         if (self.ammo_nails < 1)
  1113.             am = 1;
  1114.     }
  1115.     else if (self.impulse == 5)
  1116.     {
  1117.         fl = IT_SUPER_NAILGUN;
  1118.         extra=0;        
  1119.         if (self.ammo_nails < 2)
  1120.             am = 1;
  1121.     }
  1122.     else if (self.impulse == 6)
  1123.     {
  1124.         fl = IT_GRENADE_LAUNCHER;
  1125.         extra=0;        
  1126.         if (self.ammo_rockets < 1)
  1127.             am = 1;
  1128.     }
  1129.     else if (self.impulse == 7)
  1130.     {
  1131.         fl = IT_ROCKET_LAUNCHER;
  1132.         extra=0;        
  1133.         if (self.ammo_rockets < 1)
  1134.             am = 1;
  1135.     }
  1136.     else if (self.impulse == 8)
  1137.     {
  1138.         fl = IT_LIGHTNING;
  1139.         extra=0;        
  1140.         if (self.ammo_cells < 1)
  1141.             am = 1;
  1142.     }
  1143.     else if (self.impulse == IM_CLUSTER)
  1144.     {
  1145.         fl = WP_CLUSTER;
  1146.         extra = EXTRA_1;
  1147.         if (self.ammo_rockets < 10) 
  1148.             am=1;
  1149.     }
  1150.     else if (self.impulse ==     IM_BOUNCER)
  1151.     {
  1152.         fl = WP_BOUNCER;
  1153.         extra=EXTRA_1;
  1154.         if (self.ammo_rockets <1)
  1155.             am=1;
  1156.         if (self.ammo_nails<20)
  1157.             am=1;
  1158.     }
  1159.     else if (self.impulse == IM_FRAGROCK)
  1160.     {
  1161.         fl=WP_FRAGROCK;
  1162.         extra=EXTRA_1;
  1163.         if (self.ammo_rockets <1)
  1164.             am=1;
  1165.         if (self.ammo_nails<20)
  1166.             am=1;
  1167.     }
  1168.     else if (self.impulse == IM_LASER)
  1169.     {
  1170.         fl=WP_LASER;
  1171.         extra=EXTRA_1;
  1172.         if (self.ammo_cells<4)
  1173.             am=1;
  1174.     }
  1175.     else if (self.impulse == IM_HOMER)
  1176.     {
  1177.         fl=WP_HOMER;
  1178.         extra=EXTRA_1;
  1179.         if (self.ammo_rockets<5)
  1180.             am=1;
  1181.     }
  1182.     else if (self.impulse == IM_PHOSPHOR)
  1183.     {
  1184.         fl=WP_PHOSPHOR;
  1185.         extra=EXTRA_1;
  1186.         if (self.ammo_rockets<10)
  1187.             am=1;
  1188.     }
  1189.     else if (self.impulse == IM_LIGHTROCK)
  1190.     {
  1191.         fl=WP_LIGHTROCK;
  1192.         extra=EXTRA_1;
  1193.         if (self.ammo_rockets<1)
  1194.             am=1;
  1195.         if (self.ammo_cells<40)
  1196.             am=1;
  1197.     }
  1198.     else if (self.impulse == IM_NAPALMROCK)
  1199.     {
  1200.         fl=WP_NAPALMROCK;
  1201.         extra=EXTRA_1;
  1202.         if (self.ammo_rockets<1)
  1203.             am=1;
  1204.         if (self.ammo_cells<50)
  1205.             am=1;
  1206.     }
  1207.     else if (self.impulse == IM_NAPALMGREN)
  1208.     {
  1209.         fl=WP_NAPALMGREN;
  1210.         extra=EXTRA_1;
  1211.         if (self.ammo_rockets<1)
  1212.             am=1;
  1213.         if (self.ammo_cells<50)
  1214.             am=1;
  1215.     }
  1216.     self.impulse = 0;
  1217.     
  1218.     if (extra==0)
  1219.     {
  1220.          if (!(self.items & fl))
  1221.         { // don't have the weapon or the ammo
  1222.             sprint (self, "no weapon.\n");
  1223.             return;
  1224.         }
  1225.     }
  1226.     else if (extra==EXTRA_1)
  1227.     {
  1228.         if (!(self.weapons1 &fl))
  1229.         {
  1230.             sprint(self,"no weapon.\n");
  1231.             return;
  1232.         }
  1233.     }
  1234.     if (am)
  1235.     { // don't have the ammo
  1236.         sprint (self, "not enough ammo.\n");
  1237.         return;
  1238.     }
  1239.  
  1240. //
  1241. // set weapon, set ammo
  1242. //
  1243.     self.weapon = fl;   
  1244.     self.ef = extra;
  1245.     if (extra==EXTRA_1)
  1246.     {
  1247.         if (fl==WP_LASER)
  1248.             centerprint(self,"Laser selected\n");
  1249.         if (fl==WP_FRAGROCK)
  1250.             centerprint(self,"Fragmenation Warheads selected\n");
  1251.         if (fl==WP_BOUNCER)
  1252.             centerprint(self,"Bouncing Bettys selected\n");
  1253.         if (fl==WP_CLUSTER)
  1254.             centerprint(self,"Cluster Bombs selected\n");    
  1255.         if (fl==WP_HOMER)
  1256.             centerprint(self,"Homing missiles selected\n");
  1257.         if (fl==WP_PHOSPHOR)
  1258.             centerprint(self,"Phosphorus Grenades selected\n");
  1259.         if (fl==WP_LIGHTROCK)
  1260.             centerprint(self,"Lightning Warheads selected\n");
  1261.         if (fl==WP_NAPALMROCK)
  1262.             centerprint(self,"Napalm Warheads selected\n");
  1263.         if (fl==WP_NAPALMGREN)
  1264.             centerprint(self,"Napalm Grenades selected\n");
  1265.     }
  1266.     W_SetCurrentAmmo ();
  1267. };
  1268.  
  1269. /*
  1270. ============
  1271. CheatCommand
  1272. ============
  1273. */
  1274. void() CheatCommand =
  1275. {
  1276.     if (deathmatch || coop)
  1277.         return;
  1278.  
  1279.     self.ammo_rockets = 100;
  1280.     self.ammo_nails = 200;
  1281.     self.ammo_shells = 100;
  1282.     self.items = self.items | 
  1283.         IT_AXE |
  1284.         IT_SHOTGUN |
  1285.         IT_SUPER_SHOTGUN |
  1286.         IT_NAILGUN |
  1287.         IT_SUPER_NAILGUN |
  1288.         IT_GRENADE_LAUNCHER |
  1289.         IT_ROCKET_LAUNCHER |
  1290.         IT_KEY1 |    IT_KEY2;
  1291.     self.ammo_cells = 200;
  1292.     self.ammo_napalm = 500;
  1293.     self.items = self.items | IT_LIGHTNING;
  1294.     self.weapons1 = self.weapons1 |
  1295.         WP_CLUSTER |
  1296.         WP_BOUNCER |
  1297.         WP_FRAGROCK |
  1298.         WP_LASER |
  1299.         WP_HOMER |
  1300.         WP_PHOSPHOR |
  1301.         WP_LIGHTROCK |
  1302.         WP_NAPALMROCK |
  1303.         WP_NAPALMGREN;
  1304.     self.weapon = IT_ROCKET_LAUNCHER;
  1305.     self.ef = 0;
  1306.     self.impulse = 0;
  1307.     W_SetCurrentAmmo ();
  1308. };
  1309.  
  1310. /*
  1311. ============
  1312. CycleWeaponCommand
  1313.  
  1314. Go to the next weapon with ammo
  1315. ============
  1316. */
  1317. void() CycleWeaponCommand =
  1318. {
  1319.     local float it, am;
  1320.     
  1321.     it = self.items;
  1322.     self.impulse = 0;
  1323.     
  1324.     while (1)
  1325.     {
  1326.         am = 0;
  1327.  
  1328.         if (self.weapon == IT_LIGHTNING)
  1329.         {
  1330.             self.weapon = IT_AXE;
  1331.             self.ef = 0;                        
  1332.         }
  1333.         else if (self.weapon == IT_AXE)
  1334.         {
  1335.             self.weapon = IT_SHOTGUN;
  1336.             self.ef = 0;                        
  1337.             if (self.ammo_shells < 1)
  1338.                 am = 1;
  1339.         }
  1340.         else if (self.weapon == IT_SHOTGUN)
  1341.         {
  1342.             self.weapon = IT_SUPER_SHOTGUN;
  1343.             self.ef = 0;                        
  1344.             if (self.ammo_shells < 2)
  1345.                 am = 1;
  1346.         }   
  1347.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1348.         {
  1349.             self.weapon = IT_NAILGUN;
  1350.             self.ef = 0;                        
  1351.             if (self.ammo_nails < 1)
  1352.                 am = 1;
  1353.         }
  1354.         else if (self.weapon == IT_NAILGUN)
  1355.         {
  1356.             self.weapon = IT_SUPER_NAILGUN;
  1357.             self.ef = 0;                        
  1358.             if (self.ammo_nails < 2)
  1359.                 am = 1;
  1360.         }
  1361.         else if (self.weapon == IT_SUPER_NAILGUN)
  1362.         {
  1363.             self.weapon = IT_GRENADE_LAUNCHER;
  1364.             self.ef = 0;                        
  1365.             if (self.ammo_rockets < 1)
  1366.                 am = 1;
  1367.         }
  1368.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  1369.         {
  1370.             self.weapon = IT_ROCKET_LAUNCHER;
  1371.             self.ef = 0;                        
  1372.             if (self.ammo_rockets < 1)
  1373.                 am=1;
  1374.         }
  1375.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1376.         {
  1377.             self.weapon = IT_LIGHTNING;
  1378.             self.ef = 0;            
  1379.             if (self.ammo_cells < 1)
  1380.                 am = 1;
  1381.         }
  1382.         
  1383.         if (self.ef==EXTRA_1)
  1384.         {
  1385.             if ((self.weapons1 & self.weapon) && am ==0)
  1386.             {
  1387.                 W_SetCurrentAmmo();
  1388.                 return;
  1389.             }
  1390.         }
  1391.         else if ( (self.items & self.weapon) && am == 0)
  1392.         {
  1393.             W_SetCurrentAmmo ();
  1394.             return;
  1395.         }
  1396.     }
  1397.  
  1398. };
  1399.  
  1400. /*
  1401. ============
  1402. ServerflagsCommand
  1403.  
  1404. Just for development
  1405. ============
  1406. */
  1407. void() ServerflagsCommand =
  1408. {
  1409.     serverflags = serverflags * 2 + 1;
  1410. };
  1411.  
  1412. void() QuadCheat =
  1413. {
  1414.     if (deathmatch || coop)
  1415.         return;
  1416.     self.super_time = 1;
  1417.     self.super_damage_finished = time + 30;
  1418.     self.items = self.items | IT_QUAD;
  1419.     dprint ("quad cheat\n");
  1420. };
  1421.  
  1422. /*
  1423. ============
  1424. ImpulseCommands
  1425.  
  1426. ============
  1427. */
  1428. void() ImpulseCommands =
  1429. {
  1430.     if (self.impulse >= 1 && self.impulse <= 8)
  1431.         W_ChangeWeapon ();
  1432.  
  1433.     if (self.impulse == 9)
  1434.         CheatCommand ();
  1435.     if (self.impulse == 10)
  1436.         CycleWeaponCommand ();
  1437.     if (self.impulse == 11)
  1438.         ServerflagsCommand ();
  1439.     if (self.impulse == IM_CLUSTER)
  1440.         W_ChangeWeapon();
  1441.     if (self.impulse == IM_BOUNCER)
  1442.         W_ChangeWeapon();
  1443.     if (self.impulse == IM_FRAGROCK)
  1444.         W_ChangeWeapon();
  1445.     if (self.impulse == IM_LASER)
  1446.         W_ChangeWeapon();
  1447.     if (self.impulse == IM_HOMER)
  1448.         W_ChangeWeapon();
  1449.     if (self.impulse == IM_PHOSPHOR)
  1450.         W_ChangeWeapon();
  1451.     if (self.impulse == IM_LIGHTROCK)
  1452.         W_ChangeWeapon();
  1453.     if (self.impulse == IM_NAPALMROCK)
  1454.         W_ChangeWeapon();
  1455.     if (self.impulse == IM_NAPALMGREN)
  1456.         W_ChangeWeapon();
  1457.     
  1458.     if (self.impulse == 255)
  1459.         QuadCheat ();
  1460.         
  1461.     self.impulse = 0;
  1462. };
  1463.  
  1464. /*
  1465. ============
  1466. W_WeaponFrame
  1467.  
  1468. Called every frame so impulse events can be handled as well as possible
  1469. ============
  1470. */
  1471. void() W_WeaponFrame =
  1472. {
  1473.     if (time < self.attack_finished)
  1474.         return;
  1475.  
  1476.     ImpulseCommands ();
  1477.     
  1478. // check for attack
  1479.     if (self.button0)
  1480.     {
  1481.         SuperDamageSound ();
  1482.         W_Attack ();
  1483.     }
  1484. };
  1485.  
  1486. /*
  1487. ========
  1488. SuperDamageSound
  1489.  
  1490. Plays sound if needed
  1491. ========
  1492. */
  1493. void() SuperDamageSound =
  1494. {
  1495.     if (self.super_damage_finished > time)
  1496.     {
  1497.         if (self.super_sound < time)
  1498.         {
  1499.             self.super_sound = time + 1;
  1500.             sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
  1501.         }
  1502.     }
  1503.     return;
  1504. };