Drop Ammo on Death

Version:

2.0

Added on:

01 Dec 2014 18:36

Tags:

Description:
When you die you will drop your ammo on the ground, and you can get your ammo back.
  1. //Script by XxMoNsTeR
  2.  
  3. /*************************************************Drop Ammo on Death***********************************************/
  4.  
  5. bool droppedAmmo = false;
  6. uint realAmmoDropping = 0;
  7. int latestXPos;
  8. int latestYPos;
  9. int initialLatestXPos;
  10. int initialLatestYPos;
  11. int splitchance = 0;
  12.  
  13. void onPlayer() {
  14.     if (p.health == 0 && !droppedAmmo) {
  15.       latestXPos = p.xPos;
  16.     latestYPos = p.yPos;
  17.     initialLatestXPos = latestXPos;
  18.     initialLatestYPos = latestYPos;
  19.       p.xPos = 1 * 32;
  20.     p.yPos = 1 * 32;
  21.     realAmmoDropping = p.ammo[WEAPON::BOUNCER] / 3;
  22.     for (uint ammoDropping = 0; ammoDropping < realAmmoDropping; ammoDropping++) {
  23.       jjAddObject(OBJECT::BOUNCERAMMO3, latestXPos, latestYPos, p.playerID, CREATOR::PLAYER);
  24.       splitAmmo();
  25.     }
  26.     realAmmoDropping = p.ammo[WEAPON::ICE] / 3;
  27.     for (uint ammoDropping = 0; ammoDropping < realAmmoDropping; ammoDropping++) {
  28.       jjAddObject(OBJECT::ICEAMMO3, latestXPos, latestYPos, p.playerID, CREATOR::PLAYER);
  29.     splitAmmo();
  30.     }
  31.     realAmmoDropping = p.ammo[WEAPON::RF] / 3;
  32.     for (uint ammoDropping = 0; ammoDropping < realAmmoDropping; ammoDropping++) {
  33.       jjAddObject(OBJECT::RFAMMO3, latestXPos, latestYPos, p.playerID, CREATOR::PLAYER);
  34.     splitAmmo();
  35.     }
  36.     realAmmoDropping = p.ammo[WEAPON::SEEKER] / 3;
  37.     for (uint ammoDropping = 0; ammoDropping < realAmmoDropping; ammoDropping++) {
  38.       jjAddObject(OBJECT::SEEKERAMMO3, latestXPos, latestYPos, p.playerID, CREATOR::PLAYER);
  39.     splitAmmo();
  40.     }
  41.     realAmmoDropping = p.ammo[WEAPON::TOASTER] / 3;
  42.     for (uint ammoDropping = 0; ammoDropping < realAmmoDropping; ammoDropping++) {
  43.       jjAddObject(OBJECT::TOASTERAMMO3, latestXPos, latestYPos, p.playerID, CREATOR::PLAYER);
  44.     splitAmmo();
  45.     }
  46.     realAmmoDropping = p.ammo[WEAPON::TNT] / 3;
  47.     for (uint ammoDropping = 0; ammoDropping < realAmmoDropping; ammoDropping++) {
  48.       jjAddObject(OBJECT::TNTAMMO3, latestXPos, latestYPos, p.playerID, CREATOR::PLAYER);
  49.     splitAmmo();
  50.     }
  51.     realAmmoDropping = p.ammo[WEAPON::GUN8] / 3;
  52.     for (uint ammoDropping = 0; ammoDropping < realAmmoDropping; ammoDropping++) {
  53.       jjAddObject(OBJECT::GUN8AMMO3, latestXPos, latestYPos, p.playerID, CREATOR::PLAYER);
  54.     splitAmmo();
  55.     }
  56.     realAmmoDropping = p.ammo[WEAPON::GUN9] / 3;
  57.     for (uint ammoDropping = 0; ammoDropping < realAmmoDropping; ammoDropping++) {
  58.       jjAddObject(OBJECT::GUN9AMMO3, latestXPos, latestYPos, p.playerID, CREATOR::PLAYER);
  59.     splitAmmo();
  60.     }
  61.     droppedAmmo = true;
  62.   } else if (p.health == 5 && droppedAmmo) {
  63.       droppedAmmo = false;
  64.     p.ammo[WEAPON::BOUNCER] = 0;
  65.       p.ammo[WEAPON::GUN8] = 0;
  66.       p.ammo[WEAPON::GUN9] = 0;
  67.       p.ammo[WEAPON::TNT] = 0;
  68.       p.ammo[WEAPON::TOASTER] = 0;
  69.       p.ammo[WEAPON::SEEKER] = 0;
  70.       p.ammo[WEAPON::ICE] = 0;
  71.       p.ammo[WEAPON::RF] = 0;
  72.   }
  73. }
  74.  
  75. void splitAmmo() {
  76.     splitchance = jjRandom() % 9;
  77.   latestXPos = initialLatestXPos;
  78.   latestYPos = initialLatestYPos;
  79.   switch(splitchance) {
  80.       case 1:
  81.         latestXPos = latestXPos - jjRandom() % 33;
  82.       latestYPos = latestYPos + jjRandom() % 33;
  83.       break;
  84.     case 2:
  85.         latestYPos = latestYPos + jjRandom() % 33;
  86.         break;
  87.     case 3:
  88.         latestXPos = latestXPos + jjRandom() % 33;
  89.       latestYPos = latestYPos + jjRandom() % 33;
  90.       break;
  91.     case 4:
  92.         latestXPos = latestXPos - jjRandom() % 33;
  93.       break;
  94.     case 5:
  95.         latestXPos = latestXPos + jjRandom() % 33;
  96.       break;
  97.     case 6:
  98.         latestXPos = latestXPos - jjRandom() % 33;
  99.       latestYPos = latestYPos - jjRandom() % 33;
  100.       break;
  101.     case 7:
  102.         latestYPos = latestYPos - jjRandom() % 33;
  103.       break;
  104.     case 8:
  105.         latestXPos = latestXPos + jjRandom() % 33;
  106.       latestYPos = latestYPos - jjRandom() % 33;
  107.       break;
  108.       default:
  109.         latestXPos = latestXPos;
  110.       latestYPos = latestYPos;
  111.       break;    
  112.   }
  113. }
  114.  
  115. /************************************************************************************************************************/