Advertisement
ijontichy

classWeapons.c

Oct 27th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.12 KB | None | 0 0
  1. #include "zcommon.acs"
  2. #library "classWeapons"
  3.  
  4. #include "classWepList.h"
  5.  
  6. #define GAVEWEAPON      1
  7. #define WEAPONSTAYON    2
  8. #define NOCLASS         4
  9.  
  10. global int 6:classes[];
  11.  
  12.  
  13. script 682 (int which)
  14. {
  15.     int pln = PlayerNumber();
  16.     classes[pln] = which - 1;
  17.  
  18.     if (GetCVar("sv_cheats") == 1)
  19.     {
  20.         Print(s:"Use \"puke -689\" to get all your class' weapons\n(only when sv_cheats is 1)");
  21.     }
  22. }
  23.  
  24.  
  25. script 683 (int slot, int dropped)
  26. {
  27.     int pln = PlayerNumber();
  28.     int found;
  29.     int ret = 0;
  30.     int wep;
  31.     int ammo1; int ammo2;
  32.  
  33.     int oAmo1; int oAmo2;
  34.     int cAmo1; int cAmo2;
  35.     int dAmo1; int dAmo2;
  36.     int sAmo1; int sAmo2;
  37.     int oMax1; int oMax2;
  38.  
  39.     int check1; int check2; int check3; int check4;
  40.     int x; int y; int z;
  41.     int i;
  42.  
  43.     if (GetCVar("sv_weaponstay"))
  44.     {
  45.         ret |= WEAPONSTAYON;
  46.     }
  47.  
  48.     slot -= 1;
  49.  
  50.     found = classes[pln];
  51.  
  52.     if (found == -1)
  53.     {
  54.         ret |= NOCLASS;
  55.     }
  56.  
  57.     if (classWeps[found][slot][0] == "None")
  58.     {
  59.         SetResultValue(ret);
  60.         terminate;
  61.     }
  62.  
  63.     if (ret & NOCLASS)
  64.     {
  65.         // Tichy: for some reason, without sv_weaponstay on, this always prints
  66.         Print(s:"something broke - no classes found\nReport the weapon you picked up and the class you're using to Ijon Tichy (gztichy@lavabit.com)");
  67.         SetResultValue(ret);
  68.         terminate;
  69.     }
  70.  
  71.     ammo1 = classWeps[found][slot][WEPCOUNT+1];
  72.     ammo2 = classWeps[found][slot][WEPCOUNT+2];
  73.  
  74.     if (dropped)
  75.     {
  76.         if (ammo1 != "None")
  77.         {
  78.             oMax1 = GetAmmoCapacity(ammo1);
  79.             oAmo1 = CheckInventory(ammo1);
  80.             SetAmmoCapacity(ammo1, oMax1*4);
  81.  
  82.             if (oAmo1 == oMax1)
  83.             {
  84.                 sAmo1 = 1;
  85.             }
  86.         }
  87.  
  88.         if (ammo2 != "None")
  89.         {
  90.             oMax2 = GetAmmoCapacity(ammo2);
  91.             oAmo2 = CheckInventory(ammo2);
  92.             SetAmmoCapacity(ammo2, oMax2*4);
  93.  
  94.             if (oAmo2 == oMax2)
  95.             {
  96.                 sAmo2 = 2;
  97.             }
  98.         }
  99.     }
  100.  
  101.     for (i = 0; i < WEPCOUNT; i++)
  102.     {
  103.         wep  =  classWeps[found][slot][i];
  104.  
  105.         if (wep == "None")
  106.         {
  107.             continue;
  108.         }
  109.  
  110.         check1 = CheckInventory(wep);
  111.         check2 = ret & WEAPONSTAYON;
  112.  
  113.         if (ammo1 == "None" || sAmo1)
  114.         { check3 = 1 - sAmo1;}
  115.         else { check3 = CheckInventory(ammo1) < GetAmmoCapacity(ammo1); }
  116.  
  117.         if (ammo2 == "None" || sAmo2)
  118.         { check4 = 0; }
  119.         else { check4 = CheckInventory(ammo2) < GetAmmoCapacity(ammo2); }
  120.  
  121.  
  122.         if (!check1)
  123.         {
  124.             GiveInventory(wep, 1);
  125.             ret |= GAVEWEAPON;
  126.         }
  127.         else if (!check2 || dropped)
  128.         {
  129.             if (check3 || check4)
  130.             {
  131.                 GiveInventory(wep, 1);
  132.                 ret |= GAVEWEAPON;
  133.             }
  134.         }
  135.     }
  136.  
  137.     check1 = GAVEWEAPON;
  138.  
  139.     if (ret & check1 == check1)
  140.     {
  141.         wep = classWeps[found][slot][WEPCOUNT];
  142.  
  143.         x = GetActorX(0);
  144.         y = GetActorY(0);
  145.         z = GetActorZ(0) + 4.0;
  146.  
  147.         Spawn(wep, x, y, z);
  148.     }
  149.  
  150.     if (dropped)
  151.     {
  152.         if (ammo1 != "None")
  153.         {
  154.             cAmo1 = CheckInventory(ammo1);
  155.             dAmo1 = cAmo1 - oAmo1;
  156.             TakeInventory(ammo1, dAmo1 / 2);
  157.             SetAmmoCapacity(ammo1, oMax1);
  158.             cAmo1 = CheckInventory(ammo1);
  159.  
  160.             if (cAmo1 > oMax1)
  161.             {
  162.                 TakeInventory(ammo1, cAmo1 - oMax1);
  163.             }
  164.         }
  165.  
  166.         if (ammo2 != "None")
  167.         {
  168.             cAmo2 = CheckInventory(ammo2);
  169.             dAmo2 = cAmo2 - oAmo2;
  170.             TakeInventory(ammo2, dAmo2 / 2);
  171.             SetAmmoCapacity(ammo2, oMax2);
  172.             cAmo1 = CheckInventory(ammo1);
  173.  
  174.             if (cAmo2 > oMax2)
  175.             {
  176.                 TakeInventory(ammo2, cAmo2 - oMax2);
  177.             }
  178.         }
  179.     }
  180.  
  181.     SetResultValue(ret);
  182. }
  183.  
  184. script 684 (void)
  185. {
  186.     SetResultValue(GetActorProperty(0, APROP_DROPPED) );
  187. }
  188.  
  189.  
  190. script 689 (void)
  191. {
  192.     int i; int w;
  193.  
  194.     int a1;  int a2;
  195.     int ca1; int ca2;
  196.  
  197.     int plc = classes[PlayerNumber()];
  198.  
  199.     if (GetCVar("sv_cheats") != 0 || GameType() == 0)
  200.     {
  201.         GiveInventory("Backpack", 1);
  202.  
  203.         for (i = 0; i < SLOTCOUNT; i++)
  204.         {
  205.             w  = classWeps[plc][i][0];
  206.             a1 = classWeps[plc][i][2];
  207.             a2 = classWeps[plc][i][3];
  208.            
  209.             if (w != "None")
  210.             {
  211.                 GiveInventory(w, 1);
  212.             }
  213.  
  214.             if (a1 != "None")
  215.             {
  216.                 ca1 = CheckInventory(a1);
  217.                 GiveInventory(a1, GetAmmoCapacity(a1) - ca1);
  218.             }
  219.  
  220.             if (a2 != "None")
  221.             {
  222.                 ca2 = CheckInventory(a2);
  223.                 GiveInventory(a2, GetAmmoCapacity(a2) - ca2);
  224.             }
  225.         }
  226.  
  227.         if (GameType() == 0)
  228.         {
  229.             terminate;
  230.         }
  231.     }
  232.  
  233.     PrintBold(n:0, s:"\c- is being a cheater by calling script 689!");
  234.  
  235.     if (GetCVar("sv_cheats") == 0)
  236.     {
  237.         ClearInventory();
  238.         Delay(105);
  239.         PrintBold(s:"As such, ", n:0, s:"\c- has lost his/her/its entire inventory.");
  240.     }
  241.     else
  242.     {
  243.         Delay(105);
  244.         PrintBold(s:"But sv_cheats is true, so who cares?");
  245.     }
  246. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement