Advertisement
ijontichy

dakka_pickup.h

Mar 24th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.45 KB | None | 0 0
  1. script 649 (int index, int dropped, int weaponstay)
  2. {
  3.     int classslot = dakkaClassNum() + 1;
  4.     if (index < 0 || index >= PICKUPCOUNT) { SetResultValue(0); terminate; }
  5.  
  6.     int doPickup = 1;
  7.     int didPickup = 0;
  8.  
  9.     int ammoMult = 1.0;
  10.     if (dropped) { ammoMult /= 2; }
  11.     if (GetCVar("sv_doubleammo")) { ammoMult *= 2; }
  12.  
  13.     if (!doPickup)
  14.     {
  15.         SetResultValue(0);
  16.         terminate;
  17.     }
  18.  
  19.     int i, item, count, startcount, endcount, countinv, ammo, wep;
  20.     int oldammo;
  21.  
  22.     for (i = 0; i < PICKUPSLOTCOUNT; i++)
  23.     {
  24.         item        = DakkaPickups[classslot][index][i];
  25.         count       = DakkaPickupCounts[classslot][index][i];
  26.         countinv    = DakkaPickup_GoesIntoInventory[classslot][index][i];
  27.         ammo        = isAmmo(item);
  28.         wep         = getKnownWeaponIndex(item);
  29.  
  30.         if (ammo) { count = FixedMul(ammoMult, count); }
  31.         if (StrLen(item) == 0 || count == 0) { continue; }
  32.  
  33.         //Log(s:"Would get ", d:count, s:" of ", s:item, s:" (is ", s:cond(ammo, "", "not "),
  34.         //    s:"ammo); would ", s:cond(countinv, "", "not "), s:"count inventory");
  35.         Log(s:"We do", s:cond(wep != -1, "", "n't"), s:" know of weapon ", s:item);
  36.        
  37.         startcount = CheckInventory(item);
  38.         GiveAmmo(item, count);
  39.         endcount   = CheckInventory(item);
  40.  
  41.         if (countinv) { didPickup |= (startcount < endCount); }
  42.         else { didPickup = 1; }
  43.     }
  44.  
  45.  
  46.     if (didPickup)
  47.     {
  48.         ACS_ExecuteAlways(647, 0, PlayerNumber(), index, 0);
  49.     }
  50.  
  51.     SetResultValue(didPickup);
  52.     if (weaponstay && GetCVar("sv_weaponstay")) { SetResultValue(0); }
  53. }
  54.  
  55. script 647 (int pln, int index, int flags) clientside
  56. {
  57.     int classslot   = dakkaClassNum() + 1;
  58.     int message     = chooseMessage(classslot, index);
  59.     int silent      = !!(GetCvar("compat_silentpickup"));
  60.     int pkupSound   = DakkaPickupSounds[classslot][index];
  61.  
  62.     if (ConsolePlayerNumber() == pln)
  63.     {
  64.         Log(s:msgColors[GetCVar("msg0color")], s:message);
  65.  
  66.         if (silent)
  67.         {
  68.             LocalAmbientSound(pkupSound, 127);
  69.         }
  70.  
  71.         int r = DakkaPickupFlashes[classslot][index][0];
  72.         int g = DakkaPickupFlashes[classslot][index][1];
  73.         int b = DakkaPickupFlashes[classslot][index][2];
  74.         int i = DakkaPickupFlashes[classslot][index][3];
  75.         int t = DakkaPickupFlashes[classslot][index][4];
  76.         FadeRange(r, g, b, i, r, g, b, 0, t);
  77.     }
  78.  
  79.     if (!silent)
  80.     {
  81.         ActivatorSound(pkupSound, 127);
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement