SHARE
TWEET

Untitled

a guest May 18th, 2016 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ============
  3. W_ChangeWeapon
  4.  
  5. ============
  6. */
  7. void() W_ChangeWeapon =
  8. {
  9.     local   float   it, am, fl;
  10.       local float oldimpulse;
  11.    
  12.     it = self.items;
  13.     am = 0;
  14.    
  15.     if (self.impulse == 1)
  16.     {
  17.         fl = IT_AXE;
  18.     }
  19.     else if (self.impulse == 2)
  20.     {
  21.         fl = IT_SHOTGUN;
  22.         if (self.ammo_shells < 1)
  23.             am = 1;
  24.     }
  25.     else if (self.impulse == 3)
  26.     {
  27.         fl = IT_SUPER_SHOTGUN;
  28.         if (self.ammo_shells < 2)
  29.             am = 1;
  30.     }
  31.  
  32.     else if (self.impulse == 4)
  33.     {
  34.       if (self.weapon == IT_NAILGUN)
  35.          {
  36.          fl = IT_INFANTRY_GUN;
  37.          }
  38.       else
  39.          {
  40.          fl = IT_NAILGUN;
  41.          }
  42.         if (self.ammo_nails < 1)
  43.             am = 1;
  44.     }
  45.  
  46.     //else if (self.impulse == 4)
  47.     //{
  48.     //  if (self.weapon == IT_NAILGUN)
  49.     //  {
  50.     //      fl = IT_INFANTRY_GUN;
  51.     //  }
  52. //
  53. //      if (self.weapon == IT_INFANTRY_GUN)
  54. //      {
  55. //          fl = IT_NAILGUN;
  56. //      }
  57. //
  58. //      if (self.weapon != IT_NAILGUN)
  59. //      {
  60. //          fl = IT_NAILGUN;
  61. //      }
  62. //
  63. //      if (self.weapon != IT_INFANTRY_GUN)
  64. //      {
  65. //          fl = IT_INFANTRY_GUN;
  66. //      }
  67. //
  68. //      if (self.ammo_nails < 1)
  69. //      am = 1;
  70. //
  71. //  }
  72.  
  73.     else if (self.impulse == 5)
  74.     {
  75.       if (self.weapon == IT_SUPER_NAILGUN)
  76.          {
  77.          fl = IT_GATLING_GUN;
  78.          if (self.ammo_nails < 1)
  79.             am = 1;
  80.          }
  81.       else
  82.          {
  83.          fl = IT_SUPER_NAILGUN;
  84.          if (self.ammo_nails < 2)
  85.             am = 1;
  86.          }
  87.     }
  88.  
  89.     //else if (self.impulse == 5)
  90.     //{
  91.     //  if (self.weapon == IT_SUPER_NAILGUN)
  92.     //  {
  93.     //      fl = IT_GATLING_GUN;
  94.     //  }
  95. //
  96. //      if (self.weapon == IT_GATLING_GUN)
  97. //      {
  98. //          fl = IT_SUPER_NAILGUN;
  99. //      }
  100. //
  101. //      if (self.weapon != IT_SUPER_NAILGUN)
  102. //      {
  103. //          fl = IT_SUPER_NAILGUN;
  104. //      }
  105. //
  106. //      if (self.weapon != IT_GATLING_GUN)
  107. //      {
  108. //          fl = IT_GATLING_GUN;
  109. //      }
  110. //     
  111. //      if (self.ammo_nails < 1)
  112. //          am = 1; // < 2
  113. //  }
  114.  
  115.     else if (self.impulse == 6)
  116.     {
  117.         fl = IT_GRENADE_LAUNCHER;
  118.         if (self.ammo_rockets < 1)
  119.             am = 1;
  120.     }
  121.     else if (self.impulse == 7)
  122.     {
  123.         fl = IT_ROCKET_LAUNCHER;
  124.         if (self.ammo_rockets < 1)
  125.             am = 1;
  126.     }
  127.  
  128.     else if (self.impulse == 8)
  129.     {
  130.       if (self.weapon == IT_LIGHTNING)
  131.          {
  132.          fl = IT_BFG9500;
  133.             if (self.ammo_cells < 30)
  134.             am = 1;;
  135.          }
  136.       else
  137.          {
  138.          fl = IT_LIGHTNING;
  139.             if (self.ammo_cells < 1)
  140.             am = 1;
  141.          }
  142.  
  143.     }
  144.  
  145.     //else if (self.impulse == 8)
  146.     //{
  147.     //  if (self.weapon == IT_LIGHTNING)
  148.     //  {
  149.     //      fl = IT_BFG9500;
  150.     //      if (self.ammo_cells < 30)
  151.     //          am = 1;
  152.     //  }
  153. //
  154. //      if (self.weapon == IT_BFG9500)
  155. //      {
  156. //          fl = IT_LIGHTNING;
  157. //          if (self.ammo_cells < 1)
  158. //              am = 1;
  159. //      }
  160. //
  161. //      if (self.weapon != IT_LIGHTNING)
  162. //      {
  163. //          fl = IT_LIGHTNING;
  164. //          if (self.ammo_cells < 1)
  165. //              am = 1;
  166. //      }
  167. //
  168. //      if (self.weapon != IT_BFG9500)
  169. //      {
  170. //          fl = IT_BFG9500;
  171. //          if (self.ammo_cells < 30)
  172. //              am = 1;
  173. //      }
  174.     }
  175.     //else if (self.impulse == 9)
  176.     //{
  177.         //fl = IT_BFG9500;
  178.         //if (self.ammo_cells < 30)
  179.             //am = 1;
  180.     //}
  181.    
  182. //MED
  183.    oldimpulse = self.impulse;
  184.     self.impulse = 0;
  185.  
  186.     if (!(self.items & fl))
  187.       {
  188. //MED
  189.       if (fl == IT_NAILGUN)
  190.          {
  191.          fl = IT_INFANTRY_GUN;
  192.          if (!(self.items & fl))
  193.             {
  194.             sprint (self, "no weapon.\n");
  195.             sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  196.             return;
  197.             }
  198.          if (self.ammo_nails < 1)
  199.             am = 1;
  200.          else
  201.             am = 0;
  202.          }
  203.       else
  204.          {
  205.          sprint (self, "no weapon.\n");
  206.          sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  207.          return;
  208.          }
  209.  
  210.  
  211.       if (fl == IT_SUPER_NAILGUN)
  212.          {
  213.          fl = IT_GATLING_GUN;
  214.          if (!(self.items & fl))
  215.             {
  216.             sprint (self, "no weapon.\n");
  217.             sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  218.             return;
  219.             }
  220.          if (self.ammo_nails < 1)
  221.             am = 1;
  222.          else
  223.             am = 0;
  224.          }
  225.       else
  226.          {
  227.          sprint (self, "no weapon.\n");
  228.          sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  229.          return;
  230.          }
  231.  
  232.       if (fl == IT_LIGHTNING)
  233.          {
  234.          fl = IT_BFG9500;
  235.          if (self.ammo_cells < 30)
  236.             am = 1;
  237.          if (!(self.items & fl))
  238.             {
  239.             sprint (self, "no weapon.\n");
  240.             sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  241.             return;
  242.             }
  243.          if (self.ammo_cells < 1)
  244.             am = 1;
  245.          else
  246.             am = 0;
  247.          }
  248.       else
  249.          {
  250.          sprint (self, "no weapon.\n");
  251.          return;
  252.          }
  253.  
  254.       }
  255.  
  256.     if (!(self.items & fl))
  257.     {   // don't have the weapon or the ammo
  258.         sprint (self, "no weapon.\n");
  259.         sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  260.         return;
  261.     }
  262.    
  263.     if (am)
  264.     {   // don't have the ammo
  265.         sprint (self, "not enough ammo.\n");
  266.         sound (self, CHAN_WEAPON, "weapons/noammo.wav", 1, ATTN_NORM);
  267.         return;
  268.     }
  269.  
  270. //
  271. // set weapon, set ammo
  272. //
  273.     self.weapon = fl;      
  274.     W_SetCurrentAmmo ();
  275. };
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top