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

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