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