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

  1. void () player_run;
  2. void() SuperDamageSound;
  3. void(vector org, vector vel, float damage) SpawnBlood;
  4. void(string gibname, float dm) ThrowGib; //For explosions
  5. void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  6. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  7.  
  8. // called by worldspawn
  9. void() W_Precache =
  10. {
  11.     precache_sound2 ("blob/land1.wav");     // chain go splorch!
  12.     precache_sound ("weapons/woosh.wav");  // WOOSH sound for throwing axe
  13.     precache_sound ("weapons/taxhit1.wav");  // new ax hit sound (FROM QTEST)
  14.     precache_sound ("weapons/taxhit2.wav");  // new ax hit sound (FROM QTEST)
  15.     precache_sound ("weapons/taxhit3.wav");  // new ax hit sound (FROM QTEST)
  16.     precache_sound ("weapons/arm.wav");  // ProxBomb Arming sound
  17.     precache_sound ("weapons/r_exp3.wav");  // new rocket explosion
  18.     precache_sound ("weapons/rocket1i.wav");    // spike gun
  19.     precache_sound ("weapons/sgun1.wav");
  20.     precache_sound ("weapons/shellhit.wav"); //Shell ejection
  21.     precache_sound ("weapons/guncock.wav");    // player shotgun
  22.     precache_sound ("weapons/ric1.wav");    // ricochet (used in c code)
  23.     precache_sound ("weapons/ric2.wav");    // ricochet (used in c code)
  24.     precache_sound ("weapons/ric3.wav");    // ricochet (used in c code)
  25.     precache_sound ("weapons/spike2.wav");    // super spikes
  26.     precache_sound ("weapons/tink1.wav");    // spikes tink (used in c code)
  27.     precache_sound ("weapons/grenade.wav");    // grenade launcher
  28.     precache_sound ("weapons/bounce.wav");        // grenade bounce
  29.     precache_sound ("items/Inv1.wav");              //used in hologram
  30.     precache_sound ("items/inv2.wav");
  31.     precache_sound ("items/inv3.wav");
  32.     precache_sound ("player/hologon.wav");              //used in hologram
  33.     precache_sound ("player/holooff.wav");              //used in hologram
  34.     precache_sound ("enforcer/enfire.wav"); // player shotgun
  35.     precache_sound ("weapons/shotgn2.wav"); // super shotgun
  36.     precache_sound ("zombie/z_hit.wav"); // axe hit sound
  37.     precache_model ("progs/throwaxe.mdl");  // thrown axe model
  38.     precache_model ("progs/h_demon.mdl"); //weapon replacements
  39.     precache_model ("progs/h_dog.mdl"); //weapon replacements
  40.     precache_model ("progs/laser.mdl"); //weapon replacements
  41.     precache_model ("progs/shelcase.mdl"); //Shell ejection
  42.     precache_model ("progs/pipebomb.mdl"); //Pipe Bomb
  43.     precache_model ("progs/v_pipe.mdl"); //Pipe Bomb Player View
  44. };
  45.  
  46. float() crandom =
  47. {
  48.     return 2*(random() - 0.5);
  49. };
  50.  
  51. void(entity attacker, float recoil_val) Recoil =
  52. {
  53.         local float friction,gravity;
  54.         local vector dir,friction_vec;
  55.  
  56.         if ( !(sg_mods & FL_RECOIL) )
  57.                 return;
  58.  
  59.         dir = aim(attacker,recoil_val);
  60.         dir = normalize (dir);
  61.         recoil_val =  -10*recoil_val;
  62.         gravity = cvar ("SV_GRAVITY");
  63.         friction_vec = gravity * '0 0 1';
  64.         if (self.flags & FL_ONGROUND)
  65.         {
  66.                 friction = cvar ("SV_FRICTION");
  67.                 friction_vec = friction * dir + friction_vec;
  68.         }
  69.         attacker.velocity = recoil_val * dir + attacker.velocity + friction_vec;
  70. };
  71.  
  72. void() W_FireAxe =
  73. {
  74.     local    vector    source;
  75.     local    vector    org;
  76.  
  77.     source = self.origin + '0 0 16';
  78.     traceline (source, source + v_forward*64, FALSE, self);
  79.     if (trace_fraction == 1.0)
  80.         return;
  81.     
  82.     org = trace_endpos - v_forward*4;
  83.  
  84.     if (trace_ent.takedamage)
  85.     {
  86.         trace_ent.axhitme = 1;
  87.         SpawnBlood (org, '0 0 0', 20);
  88.         sound (self, CHAN_WEAPON, "zombie/z_hit.wav", 1, ATTN_NORM);
  89.         T_Damage (trace_ent, self, self, 20);
  90.     }
  91.     else
  92.     {    // hit wall
  93.         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  94.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  95.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  96.         WriteCoord (MSG_BROADCAST, org_x);
  97.         WriteCoord (MSG_BROADCAST, org_y);
  98.         WriteCoord (MSG_BROADCAST, org_z);
  99.     }
  100. };
  101.  
  102. vector() wall_velocity =
  103. {
  104.     local vector    vel;
  105.     
  106.     vel = normalize (self.velocity);
  107.     vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  108.     vel = vel + 2*trace_plane_normal;
  109.     vel = vel * 200;
  110.     return vel;
  111. };
  112.  
  113. void(vector org, vector vel) SpawnMeatSpray =
  114. {
  115.     local    entity missile, mpuff;
  116.     local    vector    org;
  117.  
  118.     missile = spawn ();
  119.     missile.owner = self;
  120.     missile.movetype = MOVETYPE_BOUNCE;
  121.     missile.solid = SOLID_NOT;
  122.  
  123.     makevectors (self.angles);
  124.     missile.velocity = vel;
  125.     missile.velocity_z = missile.velocity_z + 250 + 50*random();
  126.     missile.avelocity = '3000 1000 2000';
  127.     missile.nextthink = time + 1;
  128.     missile.think = SUB_Remove;
  129.     setmodel (missile, "progs/zom_gib.mdl");
  130.     setsize (missile, '0 0 0', '0 0 0');        
  131.     setorigin (missile, org);
  132. };
  133.  
  134. void(vector org, vector vel, float damage) SpawnBlood =
  135. {
  136.     particle (org, vel*0.1, 73, damage*2);
  137.         particle (org, vel*0.2, 73, damage*4);
  138.         particle (org, vel*0.3, 73, damage*8);
  139.         particle (org, vel*0.4, 73, damage*16);
  140. };
  141.  
  142. void(float damage) spawn_touchblood =
  143. {
  144.     local vector    vel;
  145.  
  146.     vel = wall_velocity () * 0.2;
  147.     SpawnBlood (self.origin + vel*0.01, vel, damage);
  148.         SpawnBlood (self.origin + vel*0.04, vel, damage+15);
  149. };
  150.  
  151. void(vector org, vector vel) SpawnChunk =
  152. {
  153.     particle (org, vel*0.02, 0, 10);
  154.         particle (org, vel*0.05, 0, 40);
  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. void(float damage, vector dir) TraceAttack =
  189. {
  190.     local    vector    vel, org;
  191.     
  192.     vel = normalize(dir + v_up*crandom() + v_right*crandom());
  193.     vel = vel + 2*trace_plane_normal;
  194.     vel = vel * 200;
  195.     org = trace_endpos - dir*4;
  196.     if (trace_ent.takedamage)
  197.     {
  198.         SpawnBlood (org, vel*0.2, damage);
  199.         AddMultiDamage (trace_ent, damage);
  200.     }
  201.     else
  202.     {
  203.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  204.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  205.         WriteCoord (MSG_BROADCAST, org_x);
  206.         WriteCoord (MSG_BROADCAST, org_y);
  207.         WriteCoord (MSG_BROADCAST, org_z);
  208.     }
  209. };
  210.  
  211. void(float shotcount, vector dir, vector spread) FireBullets =
  212. {
  213.     local    vector direction;
  214.     local    vector    src;
  215.     
  216.     makevectors(self.v_angle);
  217.         src = self.origin + v_forward*10;
  218.     src_z = self.absmin_z + self.size_z * 0.7;
  219.     ClearMultiDamage ();
  220.     while (shotcount > 0)
  221.     {
  222.         direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  223.  
  224.         traceline (src, src + direction*2048, FALSE, self);
  225.         if (trace_fraction != 1.0)
  226.             TraceAttack (4, direction);
  227.  
  228.         shotcount = shotcount - 1;
  229.     }
  230.     ApplyMultiDamage ();
  231. };
  232.  
  233. void(vector org,vector dir) eject_shell; //For shell ejection
  234. void(vector org, vector dir) Launch_Laser;
  235.  
  236. void() W_FireLaser =
  237. {
  238.        local vector org,dir;
  239.         
  240.        self.currentammo = self.ammo_shells = self.ammo_shells - 1;
  241.        self.effects = self.effects | EF_MUZZLEFLASH;
  242.        self.attack_finished = time + 0.5;
  243.        makevectors (self.v_angle);
  244.        org = self.origin + v_forward * 7.5 + '0 0 16';
  245.        dir = aim (self, 1800);
  246.        Launch_Laser(org, dir);
  247.        self.punchangle_x = -2;
  248.        Recoil (self,3); // Not too much recoil
  249.        eject_shell (self.origin + '0 0 16' + v_forward*3,dir); //eject shell
  250. };
  251.  
  252. void() W_FireShotgun =
  253. {
  254.     local vector dir;
  255.  
  256.     sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);    
  257.         self.currentammo = self.ammo_shells = self.ammo_shells - 1;
  258.     dir = aim (self, 100000);
  259.     FireBullets (6, dir, '0.04 0.04 0');
  260.         self.punchangle_x = -2;
  261.         Recoil (self,3); // Not too much recoil
  262.         eject_shell (self.origin + '0 0 16' + v_forward*3,dir); //eject shell
  263. };
  264.  
  265. void() W_FireSuperShotgun =
  266. {
  267.     local vector dir;
  268.  
  269.     if (self.currentammo == 1)
  270.     {
  271.                 W_FireLaser ();
  272.         return;
  273.     }
  274.         
  275.     sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);    
  276.     self.punchangle_x = -4;
  277.     self.currentammo = self.ammo_shells = self.ammo_shells - 2;
  278.     dir = aim (self, 100000);
  279.     FireBullets (14, dir, '0.14 0.08 0');
  280.         Recoil (self,10);
  281.         eject_shell (self.origin + '0 0 16' + v_forward*3,dir); //eject shell
  282.         eject_shell (self.origin + '0 0 16' + v_forward*3,dir);
  283. };
  284.  
  285. void()    s_explode1    =    [0,        s_explode2] {};
  286. void()    s_explode2    =    [1,        s_explode3] {};
  287. void()    s_explode3    =    [2,        s_explode4] {};
  288. void()    s_explode4    =    [3,        s_explode5] {};
  289. void()    s_explode5    =    [4,        s_explode6] {};
  290. void()    s_explode6    =    [5,        SUB_Remove] {};
  291.  
  292. void() BecomeExplosion =
  293. {
  294.     self.movetype = MOVETYPE_NONE;
  295.     self.solid = SOLID_NOT;
  296.         ThrowGib ("progs/zom_gib.mdl", -500);
  297.         ThrowGib ("progs/zom_gib.mdl", -250);
  298.         ThrowGib ("progs/zom_gib.mdl", -50);
  299.         ThrowGib ("progs/zom_gib.mdl", -25);
  300.         if ( !(self.velocity = '0 0 0') ) // And Blood too
  301.         {
  302.                 SpawnBlood (self.origin,self.velocity,500);
  303.                 SpawnBlood (self.origin,-1*self.velocity,500);
  304.                 self.velocity = '0 0 0';
  305.         }
  306.         else
  307.         {
  308.                 SpawnBlood (self.origin,'0 0 100',500);
  309.                 SpawnBlood (self.origin,'0 100 0',500);
  310.                 SpawnBlood (self.origin,'0 -100 0',500);
  311.                 SpawnBlood (self.origin,'-100 0 0',500);
  312.         }
  313.     self.touch = SUB_Null;
  314.     sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
  315.         setmodel (self, "progs/s_explod.spr");  //A little fire goes a long way
  316.         s_explode1 ();
  317. };
  318.  
  319. void() T_MissileTouch =
  320. {
  321.     local float    damg;
  322.  
  323.     if (other == self.owner)
  324.         return;        // don't explode on owner
  325.     if (pointcontents(self.origin) == CONTENT_SKY)
  326.     {
  327.         remove(self);
  328.         return;
  329.     }
  330.     damg = 100 + random()*20;
  331.     if (other.health)
  332.     {
  333.         if (other.classname == "monster_shambler")
  334.             damg = damg * 0.5;    // mostly immune
  335.         T_Damage (other, self, self.owner, damg );
  336.     }
  337.     T_RadiusDamage (self, self.owner, 120, other);
  338.     self.origin = self.origin - 8*normalize(self.velocity);
  339.     BecomeExplosion ();
  340. };
  341.  
  342. void() W_FireRocket =
  343. {
  344.     local    entity missile, mpuff;
  345.     
  346.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  347.     sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  348.         self.punchangle_x = -2;
  349.      missile = spawn ();
  350.     missile.owner = self;
  351.     missile.movetype = MOVETYPE_FLYMISSILE;
  352.     missile.solid = SOLID_BBOX;
  353.         missile.effects = EF_DIMLIGHT;
  354.     makevectors (self.v_angle);
  355.         missile.velocity = aim(self, 1500);
  356.         missile.velocity = missile.velocity * 1500;
  357.     missile.angles = vectoangles(missile.velocity);
  358.     missile.touch = T_MissileTouch;
  359.     missile.nextthink = time + 5;
  360.     missile.think = SUB_Remove;
  361.         setmodel (missile, "progs/h_demon.mdl");
  362.         setsize (missile, '0 0 0', '0 0 0');     
  363.     setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  364.         Recoil (self,20);       //Now that is some kick
  365. };
  366.  
  367. void(vector p1, vector p2, entity from, float damage) LightningDamage =
  368. {
  369.     local entity        e1, e2;
  370.     local vector        f;
  371.     
  372.     f = p2 - p1;
  373.     normalize (f);
  374.     f_x = 0 - f_y;
  375.     f_y = f_x;
  376.     f_z = 0;
  377.     f = f*16;
  378.     e1 = e2 = world;
  379.     traceline (p1, p2, FALSE, self);
  380.     if (trace_ent.takedamage)
  381.     {
  382.         particle (trace_endpos, '0 0 100', 225, damage*4);
  383.         T_Damage (trace_ent, from, from, damage);
  384.         if (self.classname == "player")
  385.         {
  386.             if (other.classname == "player")
  387.                 trace_ent.velocity_z = trace_ent.velocity_z + 400;
  388.         }
  389.     }
  390.     e1 = trace_ent;
  391.     traceline (p1 + f, p2 + f, FALSE, self);
  392.     if (trace_ent != e1 && trace_ent.takedamage)
  393.     {
  394.         particle (trace_endpos, '0 0 100', 225, damage*4);
  395.         T_Damage (trace_ent, from, from, damage);
  396.     }
  397.     e2 = trace_ent;
  398.     traceline (p1 - f, p2 - f, FALSE, self);
  399.     if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
  400.     {
  401.         particle (trace_endpos, '0 0 100', 225, damage*4);
  402.         T_Damage (trace_ent, from, from, damage);
  403.     }
  404. };
  405.  
  406.  
  407. void() W_FireLightning =
  408. {
  409.     local    vector        org;
  410.  
  411.     if (self.ammo_cells < 1)
  412.     {
  413.         self.weapon = W_BestWeapon ();
  414.         W_SetCurrentAmmo ();
  415.         return;
  416.     }
  417.     if (self.waterlevel > 1)
  418.     {
  419.         T_RadiusDamage (self, self, 35*self.ammo_cells, world);
  420.         self.ammo_cells = 0;
  421.         W_SetCurrentAmmo ();
  422.         return;
  423.     }
  424.     if (self.t_width < time)
  425.     {
  426.         sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  427.         self.t_width = time + 0.6;
  428.     }
  429.     self.punchangle_x = -2;
  430.     self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  431.     org = self.origin + '0 0 16';
  432.     traceline (org, org + v_forward*600, TRUE, self);
  433.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  434.     WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  435.     WriteEntity (MSG_BROADCAST, self);
  436.     WriteCoord (MSG_BROADCAST, org_x);
  437.     WriteCoord (MSG_BROADCAST, org_y);
  438.     WriteCoord (MSG_BROADCAST, org_z);
  439.     WriteCoord (MSG_BROADCAST, trace_endpos_x);
  440.     WriteCoord (MSG_BROADCAST, trace_endpos_y);
  441.     WriteCoord (MSG_BROADCAST, trace_endpos_z);
  442.     LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
  443. };
  444.  
  445. void() GrenadeExplode =
  446. {
  447.     T_RadiusDamage (self, self.owner, 120, world);
  448.     BecomeExplosion ();
  449. };
  450.  
  451. void() GrenadeTouch =
  452. {
  453.     if (other == self.owner)
  454.         return;        // don't explode on owner
  455.     if (other.takedamage == DAMAGE_AIM)
  456.     {
  457.         GrenadeExplode();
  458.         return;
  459.     }
  460.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);    // bounce sound
  461.     if (self.velocity == '0 0 0')
  462.         self.avelocity = '0 0 0';
  463. };
  464.  
  465. void() W_FireGrenade =
  466. {
  467.     local    entity missile, mpuff;
  468.     
  469.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  470.     sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  471.     self.punchangle_x = -2;
  472.     missile = spawn ();
  473.     missile.owner = self;
  474.     missile.movetype = MOVETYPE_BOUNCE;
  475.     missile.solid = SOLID_BBOX;
  476.     missile.classname = "grenade";
  477.     makevectors (self.v_angle);
  478.     if (self.v_angle_x)
  479.         missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  480.     else
  481.     {
  482.         missile.velocity = aim(self, 10000);
  483.         missile.velocity = missile.velocity * 600;
  484.         missile.velocity_z = 200;
  485.     }
  486.     missile.avelocity = '300 300 300';
  487.     missile.angles = vectoangles(missile.velocity);
  488.     missile.touch = GrenadeTouch;
  489.     missile.nextthink = time + 2.5;
  490.     missile.think = GrenadeExplode;
  491.         setmodel (missile, "progs/h_dog.mdl");
  492.     setsize (missile, '0 0 0', '0 0 0');        
  493.     setorigin (missile, self.origin);
  494.         Recoil (self,12);  //Pretty nice recoil huh?
  495. };
  496.  
  497. void () ProximityTouch =
  498. {
  499.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);
  500.     if (self.velocity == '0 0 0')
  501.         self.avelocity = '0 0 0';
  502. };
  503.  
  504. void () Proximity =
  505. {
  506.     local entity head;
  507.  
  508.         head = findradius(self.origin,150);
  509.         while(head)
  510.     {
  511.         if ( (head.health > 1) && (head.classname == "player") && !(head.items & IT_INVISIBILITY) )
  512.         {
  513.             sound (self, CHAN_WEAPON, "weapons/arm.wav", 1, ATTN_NORM);
  514.                         self.nextthink = time + 0.2;
  515.             self.think = GrenadeExplode;
  516.             return;
  517.         }
  518.         head = head.chain;
  519.     }
  520.         self.nextthink = time + 0.25;
  521. };
  522.  
  523. void() W_DropBomb =
  524. {
  525.     local entity item;
  526.  
  527.         if (self.ammo_rockets <= 2)
  528.         return;
  529.     self.ammo_rockets = self.ammo_rockets - 2;
  530.     self.flags = self.flags | FL_ATTACKED;
  531.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);
  532.     item = spawn();
  533.     item.owner = self;
  534.     makevectors(self.v_angle);
  535.         setorigin(item,self.origin - '0 0 17');
  536.         item.velocity= '0 0 0';
  537.         item.avelocity='0 800 800';
  538.     item.flags = FL_ITEM;
  539.         item.solid = SOLID_BBOX;
  540.         item.movetype = MOVETYPE_FLY;
  541.     item.classname = "proximity";
  542.         item.health = 20;
  543.         item.th_die = GrenadeExplode;
  544.         item.takedamage = DAMAGE_AIM;
  545.     setmodel (item, "progs/grenade.mdl");
  546.         setsize (item, '-48 -48 -4', '48 48 4');            
  547.         item.nextthink = time + 3;
  548.     item.think = Proximity;
  549.     W_SetCurrentAmmo();
  550. };
  551.  
  552. .float hit_z;
  553. void() spike_touch =
  554. {
  555. local float rand;
  556.     if (other == self.owner)
  557.         return;
  558.     if (other.solid == SOLID_TRIGGER)
  559.         return;    // trigger field, do nothing
  560.     if (pointcontents(self.origin) == CONTENT_SKY)
  561.     {
  562.         remove(self);
  563.         return;
  564.     }
  565.     if (other.takedamage)
  566.     {
  567.         spawn_touchblood (9);
  568.         T_Damage (other, self, self.owner, 9);
  569.     }
  570.     else
  571.     {
  572.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  573.         if (self.classname == "wizspike")
  574.             WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  575.         else if (self.classname == "knightspike")
  576.             WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  577.         else
  578.             WriteByte (MSG_BROADCAST, TE_SPIKE);
  579.         WriteCoord (MSG_BROADCAST, self.origin_x);
  580.         WriteCoord (MSG_BROADCAST, self.origin_y);
  581.         WriteCoord (MSG_BROADCAST, self.origin_z);
  582.     }
  583.     remove(self);
  584. };
  585.  
  586. void() superspike_touch =
  587. {
  588. local float rand;
  589.     if (other == self.owner)
  590.         return;
  591.     if (other.solid == SOLID_TRIGGER)
  592.         return;    // trigger field, do nothing
  593.     if (pointcontents(self.origin) == CONTENT_SKY)
  594.     {
  595.         remove(self);
  596.         return;
  597.     }
  598.     if (other.takedamage)
  599.     {
  600.         spawn_touchblood (18);
  601.         T_Damage (other, self, self.owner, 18);
  602.     }
  603.     else
  604.     {
  605.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  606.         WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
  607.         WriteCoord (MSG_BROADCAST, self.origin_x);
  608.         WriteCoord (MSG_BROADCAST, self.origin_y);
  609.         WriteCoord (MSG_BROADCAST, self.origin_z);
  610.     }
  611.     remove(self);
  612. };
  613.  
  614. void(vector org, vector dir) launch_hologram;
  615.  
  616. void(float ox) W_FireHologram =      //Used to setup and launch the HOLOGRAM
  617. {
  618.  
  619.     local vector    dir;
  620.     
  621.     makevectors (self.v_angle);
  622.     self.attack_finished = time + 0.5;
  623.     dir = aim (self, 1000);
  624.         launch_hologram (self.origin + '0 0 24' + v_right*ox, dir);
  625. };
  626.  
  627. void(vector org, vector dir) launch_spike =
  628. {
  629.     newmis = spawn ();
  630.     newmis.owner = self;
  631.     newmis.movetype = MOVETYPE_FLYMISSILE;
  632.     newmis.solid = SOLID_BBOX;
  633.     newmis.angles = vectoangles(dir);
  634.     newmis.touch = spike_touch;
  635.     newmis.classname = "spike";
  636.     newmis.think = SUB_Remove;
  637.     newmis.nextthink = time + 6;
  638.     setmodel (newmis, "progs/spike.mdl");
  639.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  640.     setorigin (newmis, org);
  641.     newmis.velocity = dir * 1000;
  642. };
  643.  
  644. void() W_FireSuperSpikes =
  645. {
  646.     local vector    dir;
  647.     local entity    old;
  648.     
  649.     sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  650.     self.attack_finished = time + 0.2;
  651.     self.currentammo = self.ammo_nails = self.ammo_nails - 2;
  652.     dir = aim (self, 1000);
  653.     launch_spike (self.origin + '0 0 16', dir);
  654.     newmis.touch = superspike_touch;
  655.     setmodel (newmis, "progs/s_spike.mdl");
  656.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  657.     self.punchangle_x = -2;
  658.         Recoil (self,5);        //Just hold that attack button down
  659. };
  660.  
  661. void(float ox) W_FireSpikes =
  662. {
  663.     local vector    dir;
  664.     local entity    old;
  665.     
  666.     makevectors (self.v_angle);
  667.     if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
  668.     {
  669.         W_FireSuperSpikes ();
  670.         return;
  671.     }
  672.     if (self.ammo_nails < 1)
  673.     {
  674.         self.weapon = W_BestWeapon ();
  675.         W_SetCurrentAmmo ();
  676.         return;
  677.     }
  678.     sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
  679.     self.attack_finished = time + 0.2;
  680.     self.currentammo = self.ammo_nails = self.ammo_nails - 1;
  681.     dir = aim (self, 1000);
  682.     launch_spike (self.origin + '0 0 16' + v_right*ox, dir);
  683.     self.punchangle_x = -2;
  684.         Recoil (self,2);   //Seems small now, go to E1M8
  685. };
  686.  
  687. void(vector org, vector dir) launch_flare;
  688.  
  689. void() W_FireFlare =
  690. {
  691.         local vector org,dir;
  692.         
  693.         self.attack_finished = time + 0.5;
  694.         makevectors (self.v_angle);
  695.         org = self.origin + v_forward * 7.5 + '0 0 16';
  696.         dir = aim (self, 1800);
  697.         launch_flare(org, dir);
  698.     self.punchangle_x = -2;
  699. };
  700.  
  701. void() DetPipeBombs =
  702. {
  703.         local entity    head;
  704.  
  705.         self.flags = self.flags | FL_ATTACKED; //says that you have attacked for teamplay
  706.         head = findradius (self.origin, 1000);
  707.         while(head)
  708.         {
  709.                 if(head.classname == "pipebomb" || head.classname == "proximity")
  710.                         if (head.owner == self)
  711.                         {
  712.                                 sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
  713.                                 head.nextthink = time;
  714.                         }
  715.                 head = head.chain;
  716.         }
  717. };
  718.  
  719. void() PipeBombTouch =
  720. {
  721.     if (other == self.owner)
  722.         return;        // don't explode on owner
  723.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);    // bounce sound
  724.     if (self.velocity == '0 0 0')
  725.         self.avelocity = '0 0 0';
  726. };
  727.  
  728. void() W_FirePipeBomb =
  729. {
  730.     local    entity missile, mpuff;
  731.     
  732.     if(self.ammo_rockets < 4)       // have to have enough ammo
  733.         return;
  734.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 4;
  735.     self.flags = self.flags | FL_ATTACKED; //says that you have attacked for teamplay
  736.     sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  737.     self.punchangle_x = -2;
  738.     missile = spawn ();
  739.     missile.owner = self;
  740.     missile.movetype = MOVETYPE_BOUNCE;
  741.     missile.solid = SOLID_BBOX;
  742.     missile.classname = "pipebomb";
  743.     makevectors (self.v_angle);
  744.     if (self.v_angle_x)
  745.         missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  746.     else
  747.     {
  748.         missile.velocity = aim(self, 10000);
  749.         missile.velocity = missile.velocity * 600;
  750.         missile.velocity_z = 200;
  751.     }
  752.     missile.avelocity = '300 300 300';
  753.     missile.angles = vectoangles(missile.velocity);
  754.     missile.touch = PipeBombTouch;
  755.     missile.think = GrenadeExplode;
  756.     setmodel (missile, "progs/pipebomb.mdl");
  757.     setsize (missile, '0 0 0', '0 0 0');        
  758.     setorigin (missile, self.origin);
  759.     Recoil(self,4);
  760. };
  761.  
  762. void() W_SetCurrentAmmo =
  763. {
  764.  if(self.classname != "player")
  765.    return;
  766.     player_run ();        // get out of any weapon firing states
  767.  
  768.     self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
  769.     
  770.     if (self.weapon == IT_AXE)
  771.     {
  772.         self.currentammo = 0;
  773.         self.weaponmodel = "progs/v_axe.mdl";
  774.         self.weaponframe = 0;
  775.     }
  776.         else if (self.weapon == IT_THROWING_AXE)
  777.     {
  778.                 self.currentammo = self.num_axes;
  779.         self.weaponmodel = "progs/v_axe.mdl";
  780.         self.weaponframe = 0;
  781.                 
  782.     }
  783.         else if (self.weapon == IT_MORNINGSTAR)
  784.         {
  785.                 self.currentammo = 0;
  786.                 self.weaponmodel = "progs/v_star.mdl";
  787.                 self.weaponframe = 0;
  788.         }
  789.     else if (self.weapon == IT_SHOTGUN)
  790.     {
  791.         self.currentammo = self.ammo_shells;
  792.         self.weaponmodel = "progs/v_shot.mdl";
  793.         self.weaponframe = 0;
  794.         self.items = self.items | IT_SHELLS;
  795.     }
  796.     else if (self.weapon == IT_SUPER_SHOTGUN)
  797.     {
  798.         self.currentammo = self.ammo_shells;
  799.         self.weaponmodel = "progs/v_shot2.mdl";
  800.         self.weaponframe = 0;
  801.         self.items = self.items | IT_SHELLS;
  802.     }
  803.     else if (self.weapon == IT_NAILGUN)
  804.     {
  805.         self.currentammo = self.ammo_nails;
  806.         self.weaponmodel = "progs/v_nail.mdl";
  807.         self.weaponframe = 0;
  808.         self.items = self.items | IT_NAILS;
  809.     }
  810.     else if (self.weapon == IT_SUPER_NAILGUN)
  811.     {
  812.         self.currentammo = self.ammo_nails;
  813.         self.weaponmodel = "progs/v_nail2.mdl";
  814.         self.weaponframe = 0;
  815.         self.items = self.items | IT_NAILS;
  816.     }
  817.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  818.     {
  819.         self.currentammo = self.ammo_rockets;
  820.         self.weaponmodel = "progs/v_rock.mdl";
  821.         self.weaponframe = 0;
  822.         self.items = self.items | IT_ROCKETS;
  823.     }
  824.     else if (self.weapon == IT_PIPE_BOMB)
  825.     {
  826.         self.currentammo = self.ammo_rockets;
  827.         self.weaponmodel = "progs/v_pipe.mdl";
  828.         self.weaponframe = 0;
  829.         self.items = self.items | IT_ROCKETS;
  830.     }    else if (self.weapon == IT_ROCKET_LAUNCHER)
  831.     {
  832.         self.currentammo = self.ammo_rockets;
  833.         self.weaponmodel = "progs/v_rock2.mdl";
  834.         self.weaponframe = 0;
  835.         self.items = self.items | IT_ROCKETS;
  836.     }
  837.     else if (self.weapon == IT_LIGHTNING)
  838.     {
  839.         self.currentammo = self.ammo_cells;
  840.         self.weaponmodel = "progs/v_light.mdl";
  841.         self.weaponframe = 0;
  842.         self.items = self.items | IT_CELLS;
  843.     }
  844.     else
  845.     {
  846.         self.currentammo = 0;
  847.         self.weaponmodel = "";
  848.         self.weaponframe = 0;
  849.     }
  850. };
  851.  
  852. float() W_BestWeapon =
  853. {
  854.     local    float    it;
  855.     
  856.     it = self.items;
  857.         if(self.ammo_cells >= 1 && (it & IT_LIGHTNING) && (self.waterlevel <= 1))
  858.         return IT_LIGHTNING;
  859.     else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
  860.         return IT_SUPER_NAILGUN;
  861.     else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
  862.         return IT_SUPER_SHOTGUN;
  863.     else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
  864.         return IT_NAILGUN;
  865.     else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
  866.         return IT_SHOTGUN;
  867.     return IT_AXE;
  868. };
  869.  
  870. float() W_CheckNoAmmo =
  871. {
  872.     if (self.currentammo > 0)
  873.         return TRUE;
  874.         if (self.weapon == IT_AXE || self.weapon == IT_MORNINGSTAR)
  875.         return TRUE;
  876.         self.weapon = W_BestWeapon ();
  877.     W_SetCurrentAmmo ();
  878.     return FALSE;
  879. };
  880.  
  881. void()    player_axe1;
  882. void()    player_axeb1;
  883. void()    player_axec1;
  884. void()    player_axed1;
  885. void()    player_shot1;
  886. void()    player_nail1;
  887. void()    player_light1;
  888. void()    player_rocket1;
  889. void()  player_tax1; //thrown axes
  890. void()    player_chain1;
  891. void()  player_chain3;
  892.  
  893. void() W_Attack =
  894. {
  895.     local    float    r;
  896.  
  897.     if (!W_CheckNoAmmo ())
  898.         return;
  899.  
  900.     makevectors    (self.v_angle);            // calculate forward angle for velocity
  901.     self.show_hostile = time + 1;    // wake monsters up
  902.         self.flags = self.flags | FL_ATTACKED; //says that you have attacked for teamplay
  903.     if (self.weapon == IT_AXE)
  904.     {
  905.         sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  906.         r = random();
  907.         if (r < 0.25)
  908.             player_axe1 ();
  909.         else if (r<0.5)
  910.             player_axeb1 ();
  911.         else if (r<0.75)
  912.             player_axec1 ();
  913.         else
  914.             player_axed1 ();
  915.         self.attack_finished = time + 0.5;
  916.     }
  917.         else if (self.weapon == IT_THROWING_AXE)
  918.     {
  919.                 player_tax1 ();
  920.  
  921.                 self.attack_finished = time + 1;
  922.     }
  923.         else if (self.weapon == IT_MORNINGSTAR)
  924.         {
  925.                 if (!self.hook_out) {player_chain1();}
  926.                 else {player_chain3();}
  927.                 self.attack_finished = time + 0.1;
  928.         }
  929.     else if (self.weapon == IT_SHOTGUN)
  930.     {
  931.         player_shot1 ();
  932.                 W_FireLaser ();
  933.         self.attack_finished = time + 0.5;
  934.     }
  935.     else if (self.weapon == IT_SUPER_SHOTGUN)
  936.     {
  937.         player_shot1 ();
  938.         W_FireSuperShotgun ();
  939.         self.attack_finished = time + 0.7;
  940.     }
  941.     else if (self.weapon == IT_NAILGUN)
  942.     {
  943.         player_nail1 ();
  944.     }
  945.     else if (self.weapon == IT_SUPER_NAILGUN)
  946.     {
  947.         player_nail1 ();
  948.     }
  949.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  950.     {
  951.         player_rocket1();
  952.         W_FireGrenade();
  953.         self.attack_finished = time + 0.6;
  954.     }
  955.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  956.     {
  957.         player_rocket1();
  958.         W_FireRocket();
  959.         self.attack_finished = time + 0.8;
  960.     }
  961.     else if (self.weapon == IT_LIGHTNING)
  962.     {
  963.         player_light1();
  964.         self.attack_finished = time + 0.1;
  965.         sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  966.     }
  967.     else if (self.weapon == IT_PIPE_BOMB)
  968.     {
  969.         player_rocket1();
  970.         W_FirePipeBomb();
  971.         self.attack_finished = time + 0.4;
  972.     }
  973. };
  974.  
  975. void() W_ChangeWeapon =
  976. {
  977.     local    float    it, am, fl;
  978.  
  979.     it = self.items;
  980.     am = 0;
  981.     if (self.impulse == 1)
  982.     {
  983.                 if (self.weapon == IT_AXE)
  984.                 {
  985.                         sprint(self,"Throwing Axe!\n");
  986.                         fl=IT_THROWING_AXE;
  987.                         if (self.num_axes <1)
  988.                                 am = 1;
  989.                 }
  990.                 else if ( (self.weapon == IT_THROWING_AXE) && (sg_mods & FL_STAR) )
  991.                 {
  992.                         sprint(self,"Morning Star!\n");
  993.                         fl=IT_MORNINGSTAR;
  994.                 }
  995.                 else
  996.                 {
  997.                         sprint(self,"Normal Axe!\n");
  998.                         fl = IT_AXE;
  999.                 }                
  1000.     }
  1001.     else if (self.impulse == 2)
  1002.     {
  1003.         fl = IT_SHOTGUN;
  1004.         if (self.ammo_shells < 1)
  1005.             am = 1;
  1006.     }
  1007.     else if (self.impulse == 3)
  1008.     {
  1009.         fl = IT_SUPER_SHOTGUN;
  1010.         if (self.ammo_shells < 2)
  1011.             am = 1;
  1012.     }        
  1013.     else if (self.impulse == 4)
  1014.     {
  1015.         fl = IT_NAILGUN;
  1016.         if (self.ammo_nails < 1)
  1017.             am = 1;
  1018.     }
  1019.     else if (self.impulse == 5)
  1020.     {
  1021.         fl = IT_SUPER_NAILGUN;
  1022.         if (self.ammo_nails < 2)
  1023.             am = 1;
  1024.     }
  1025.     else if (self.impulse == 6)
  1026.     {
  1027.                 if ( (self.weapon == IT_GRENADE_LAUNCHER) && (sg_mods & FL_PIPE) )
  1028.                 {
  1029.                         fl = IT_PIPE_BOMB;
  1030.             centerprint(self,"PipeBomb Mode\n");
  1031.                 }
  1032.                 else
  1033.                 {                        
  1034.                         fl = IT_GRENADE_LAUNCHER;
  1035.             centerprint(self,"Grenade Launcher Mode\n");
  1036.                 }
  1037.         if (self.ammo_rockets < 1)
  1038.             am = 1;
  1039.     }
  1040.     else if (self.impulse == 7)
  1041.     {
  1042.         fl = IT_ROCKET_LAUNCHER;
  1043.         if (self.ammo_rockets < 1)
  1044.             am = 1;
  1045.     }
  1046.     else if (self.impulse == 8)
  1047.     {
  1048.         fl = IT_LIGHTNING;
  1049.         if (self.ammo_cells < 1)
  1050.             am = 1;
  1051.     }
  1052.     self.impulse = 0;
  1053.     if (!(self.items & fl))
  1054.     {    // don't have the weapon or the ammo
  1055.         sprint (self, "no weapon.\n");
  1056.         return;
  1057.     }
  1058.     if (am)
  1059.     {    // don't have the ammo
  1060.         sprint (self, "not enough ammo.\n");
  1061.         return;
  1062.     }
  1063.     self.weapon = fl;        
  1064.     W_SetCurrentAmmo ();
  1065. };
  1066.  
  1067. void() CheatCommand =
  1068. {
  1069.     if (deathmatch || coop)
  1070.         return;
  1071.  
  1072.     self.ammo_rockets = 100;
  1073.     self.ammo_nails = 200;
  1074.     self.ammo_shells = 100;
  1075.     self.num_axes = 100;
  1076.     self.items = self.items | 
  1077.         IT_AXE |
  1078.         IT_SHOTGUN |
  1079.         IT_SUPER_SHOTGUN |
  1080.         IT_NAILGUN |
  1081.         IT_SUPER_NAILGUN |
  1082.         IT_GRENADE_LAUNCHER |
  1083.         IT_ROCKET_LAUNCHER |
  1084.         IT_KEY1 | IT_KEY2;
  1085.  
  1086.     self.ammo_cells = 200;
  1087.     self.items = self.items | IT_LIGHTNING;
  1088.     self.weapon = IT_ROCKET_LAUNCHER;
  1089.     self.impulse = 0;
  1090.     W_SetCurrentAmmo ();
  1091. };
  1092.  
  1093. void() CycleWeaponCommand =
  1094. {
  1095.     local    float    it, am;
  1096.     
  1097.     it = self.items;
  1098.     self.impulse = 0;
  1099.     while (1)
  1100.     {
  1101.         am = 0;
  1102.         if (self.weapon == IT_LIGHTNING)
  1103.         {
  1104.             self.weapon = IT_AXE;
  1105.         }
  1106.                 else if (self.weapon == IT_AXE || self.weapon == IT_THROWING_AXE || self.weapon == IT_MORNINGSTAR)
  1107.         {
  1108.             self.weapon = IT_SHOTGUN;
  1109.             if (self.ammo_shells < 1)
  1110.                 am = 1;
  1111.         }
  1112.         else if (self.weapon == IT_SHOTGUN)
  1113.         {
  1114.             self.weapon = IT_SUPER_SHOTGUN;
  1115.             if (self.ammo_shells < 2)
  1116.                 am = 1;
  1117.         }        
  1118.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1119.         {
  1120.             self.weapon = IT_NAILGUN;
  1121.             if (self.ammo_nails < 1)
  1122.                 am = 1;
  1123.         }
  1124.         else if (self.weapon == IT_NAILGUN)
  1125.         {
  1126.             self.weapon = IT_SUPER_NAILGUN;
  1127.             if (self.ammo_nails < 2)
  1128.                 am = 1;
  1129.         }
  1130.         else if (self.weapon == IT_SUPER_NAILGUN)
  1131.         {
  1132.             self.weapon = IT_GRENADE_LAUNCHER;
  1133.             if (self.ammo_rockets < 1)
  1134.                 am = 1;
  1135.         }
  1136.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  1137.         {
  1138.                         self.weapon = IT_PIPE_BOMB;
  1139.             if (self.ammo_rockets < 1)
  1140.                 am = 1;
  1141.         }
  1142.                 else if (self.weapon == IT_PIPE_BOMB)
  1143.         {
  1144.                         self.weapon = IT_ROCKET_LAUNCHER;
  1145.             if (self.ammo_rockets < 1)
  1146.                 am = 1;
  1147.         }
  1148.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1149.         {
  1150.             self.weapon = IT_LIGHTNING;
  1151.             if (self.ammo_cells < 1)
  1152.                 am = 1;
  1153.         }
  1154.     
  1155.         if ( (self.items & self.weapon) && am == 0)
  1156.         {
  1157.             W_SetCurrentAmmo ();
  1158.             return;
  1159.         }
  1160.     }
  1161. };
  1162.  
  1163. void() ServerflagsCommand =
  1164. {
  1165.     serverflags = serverflags * 2 + 1;
  1166. };
  1167.  
  1168. void() QuadCheat =
  1169. {
  1170.     if (deathmatch || coop)
  1171.         return;
  1172.     self.super_time = 1;
  1173.     self.super_damage_finished = time + 30;
  1174.     self.items = self.items | IT_QUAD;
  1175. };
  1176.  
  1177. void() backpack_explode;
  1178. void() ThrowBackpack =
  1179. {
  1180.     local entity     item;
  1181.  
  1182.     if ( (self.ammo_shells + self.ammo_nails + self.ammo_rockets + self.ammo_cells) == 0)
  1183.         return;
  1184.     item = spawn();
  1185.         if ( self.ammo_shells >= 20)
  1186.     {
  1187.         item.ammo_shells = 20;
  1188.         self.ammo_shells = self.ammo_shells - 20;
  1189.     }
  1190.     else
  1191.     {
  1192.         item.ammo_shells = self.ammo_shells;
  1193.         self.ammo_shells = 0;
  1194.     }
  1195.     
  1196.         if ( self.ammo_nails >= 20)
  1197.     {
  1198.         item.ammo_nails = 20;
  1199.                 self.ammo_nails = self.ammo_nails - 20;
  1200.     }
  1201.     else
  1202.     {
  1203.         item.ammo_nails = self.ammo_nails;
  1204.         self.ammo_nails = 0;
  1205.     }
  1206.  
  1207.     if ( self.ammo_rockets >= 10)
  1208.     {
  1209.         item.ammo_rockets = 10;
  1210.         self.ammo_rockets = self.ammo_rockets - 10;
  1211.     }
  1212.     else
  1213.     {
  1214.         item.ammo_rockets = self.ammo_rockets;
  1215.                 self.ammo_rockets = 0;
  1216.     }
  1217.  
  1218.     if (self.ammo_cells >= 20)
  1219.     {    
  1220.         item.ammo_cells = 20;
  1221.         self.ammo_cells = self.ammo_cells - 20;
  1222.     }
  1223.     else
  1224.     {
  1225.         item.ammo_cells = self.ammo_cells;
  1226.         self.ammo_cells = 0;
  1227.     }
  1228.     makevectors(self.v_angle);
  1229.     item.velocity = aim(self, 1000);
  1230.         item.velocity = 500 * item.velocity;
  1231.         setorigin(item, self.origin + '0 0 40');
  1232.     item.flags = FL_ITEM;
  1233.         item.solid = SOLID_SLIDEBOX;
  1234.         item.movetype = MOVETYPE_TOSS;
  1235.         setmodel (item, "progs/backpack.mdl");
  1236.         setsize(item, '-16 -16 0', '16 16 56');
  1237.     item.touch = BackpackTouch;
  1238.         if ( (item.ammo_rockets) && (sg_mods & FL_BACKEX) )
  1239.         {
  1240.                 item.health = 30;
  1241.                 item.th_die = backpack_explode;
  1242.                 item.takedamage = DAMAGE_AIM;
  1243.         }
  1244.         else
  1245.                 item.takedamage = DAMAGE_NO;
  1246.     item.nextthink = time + 120;    // remove after 2 minutes
  1247.         item.think = SUB_Remove;
  1248.     W_SetCurrentAmmo();
  1249. };
  1250.  
  1251. void() feign;   // feign death
  1252. void(entity me)     CameraOn;
  1253. void(entity me)     CameraOff;
  1254. void(entity ex) hologram_explode;
  1255.  
  1256. void() ImpulseCommands =
  1257. {
  1258.         if ( (self.impulse == 150) && (sg_mods & FL_FEIGNDEATH) )
  1259.         {
  1260.                 feign ();
  1261.                 self.impulse = 0;
  1262.         }
  1263.       if (self.flags & FL_ISFEIGN)
  1264.             return;
  1265.  
  1266.       if (self.impulse >= 1 && self.impulse <= 8)
  1267.             W_ChangeWeapon ();
  1268.       if (self.impulse == 9)
  1269.             CheatCommand ();
  1270.       if (self.impulse == 10)
  1271.             CycleWeaponCommand ();
  1272.       if (self.impulse == 11)
  1273.             ServerflagsCommand ();
  1274.       if (self.impulse == 20)
  1275.             ThrowBackpack();
  1276.       if ( (self.impulse == 21) && (sg_mods & FL_PROXIMITY) )
  1277.             W_DropBomb();
  1278.       if (self.impulse == 30)
  1279.             W_FireFlare ();  
  1280.       if ( (self.impulse == 31) && (sg_mods & FL_HOLOGRAM) ) // Activate/Deactivate hologram
  1281.       {
  1282.         if (self.holo > 0)
  1283.         {
  1284.                 hologram_explode(self.myhologram);
  1285.                 sprint (self, "Hologram off...\n");
  1286.                 self.holo = 0;
  1287.         }
  1288.         else
  1289.                 W_FireHologram ();
  1290.       }
  1291.       if (self.impulse == 33)  // Use for right turning of hologram
  1292.       {
  1293.                 if (self.holo > 0)
  1294.                         hologram.angles_y = hologram.angles_y - 5;
  1295.       }
  1296.       if (self.impulse == 34)  // Use for left turning of hologram
  1297.       {
  1298.                 if (self.holo > 0)
  1299.                         hologram.angles_y = hologram.angles_y + 5;
  1300.       }
  1301.       if (self.impulse == 36)
  1302.       {
  1303.                 if (self.holo <=0)
  1304.                         sprint (self,"Hologram must be activated first...\n");
  1305.                 else if (self.camera <= 0)
  1306.                 {
  1307.                         self.camera = 1;
  1308.                         CameraOn(self);
  1309.                 }
  1310.                 else
  1311.                 {
  1312.                         self.camera = 0;
  1313.                         CameraOff(self);  //NezuCamera(self);
  1314.                 }
  1315.       }
  1316.       if ( (self.impulse == 62) && (sg_mods & FL_PIPE) )
  1317.                 DetPipeBombs();
  1318.       if ((self.impulse == 200) || (self.impulse == 201))
  1319.       {
  1320.                 if ( (self.flags & FL_ATTACKED) && (teamplay) )
  1321.                 {
  1322.                         self.classname = "skinchange";
  1323.                         T_Damage (self, self, self, 50000);
  1324.                         return;
  1325.                 }else if (self.impulse == 200)
  1326.         {
  1327.                         self.skin = self.skin + 1;
  1328.                         if (self.skin == 19) self.skin = 0;
  1329.                 } else if (self.impulse == 201)
  1330.         {
  1331.                         self.skin = self.skin - 1;
  1332.                         if (self.skin == -1) self.skin = 18;
  1333.         }
  1334.                 if (self.skin == 0) sprint(self,"SKIN: Quake himself (1)\n"); else
  1335.                 if (self.skin == 1) sprint(self,"SKIN: BioMan (2)\n"); else
  1336.                 if (self.skin == 2) sprint(self,"SKIN: Duke Nukem 3d (3)\n"); else
  1337.                 if (self.skin == 3) sprint(self,"SKIN: NYPD Cop (4)\n"); else
  1338.                 if (self.skin == 4) sprint(self,"SKIN: Mr. Rage (5)\n"); else
  1339.                 if (self.skin == 5) sprint(self,"SKIN: MoleMan (6)\n"); else
  1340.                 if (self.skin == 6) sprint(self,"SKIN: The Evil Eye (7)\n"); else
  1341.                 if (self.skin == 7) sprint(self,"SKIN: Ninja (8)\n"); else
  1342.                 if (self.skin == 8) sprint(self,"SKIN: Mr. Toad (9)\n"); else
  1343.                 if (self.skin == 9) sprint(self,"SKIN: the Predator (10)\n"); else
  1344.                 if (self.skin == 10) sprint(self,"SKIN: Judge Dredd (11)\n"); else
  1345.                 if (self.skin == 11) sprint(self,"SKIN: the Terminator (12)\n"); else
  1346.                 if (self.skin == 12) sprint(self,"SKIN: C-3PO (13)\n"); else
  1347.                 if (self.skin == 13) sprint(self,"SKIN: the Stormtrooper (14)\n"); else
  1348.                 if (self.skin == 14) sprint(self,"SKIN: Boba (15)\n"); else
  1349.                 if (self.skin == 15) sprint(self,"SKIN: Bossk (16)\n"); else
  1350.                 if (self.skin == 16) sprint(self,"SKIN: Han Solo (17)\n"); else
  1351.                 if (self.skin == 17) sprint(self,"SKIN: Crusader (18)\n"); else
  1352.             if (self.skin == 18) sprint(self,"SKIN: Alien Dude (19)\n"); 
  1353.       }
  1354.       if (self.impulse == 255)
  1355.                 QuadCheat ();
  1356.       self.impulse = 0;
  1357. };
  1358.  
  1359. void() W_WeaponFrame =
  1360. {
  1361.     if (time < self.attack_finished)
  1362.         return;
  1363.  
  1364.     ImpulseCommands ();
  1365.     
  1366.     if (self.button0)
  1367.     {
  1368.         SuperDamageSound ();
  1369.         W_Attack ();
  1370.     }
  1371. };
  1372.  
  1373. void() SuperDamageSound =
  1374. {
  1375.     if (self.super_damage_finished > time)
  1376.     {
  1377.         if (self.super_sound < time)
  1378.         {
  1379.             self.super_sound = time + 1;
  1380.             sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
  1381.         }
  1382.     }
  1383.     return;
  1384. };
  1385.