Advertisement
BigETI

Weapon.java

Jan 16th, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.57 KB | None | 0 0
  1. //package sa_mp_srv;
  2.  
  3. import net.gtaun.shoebill.constant.WeaponModel;
  4. import net.gtaun.shoebill.data.WeaponData;
  5.  
  6. public class Weapon extends WeaponData {
  7.    
  8.     private static final long serialVersionUID = 8903790067683232090L;
  9.  
  10.     public static enum WEAPON_SLOT
  11.     {
  12.         INVALID,
  13.         HAND,
  14.         MELEE,
  15.         PISTOL,
  16.         SHOTGUN,
  17.         MACHINE_PISTOL,
  18.         CARABINER,
  19.         RIFLE,
  20.         HEAVY,
  21.         THROWABLE,
  22.         MISC1,
  23.         MISC2,
  24.         WEARABLE,
  25.         DETONATOR
  26.     }
  27.    
  28.     public Weapon()
  29.     {
  30.         this.model = WeaponModel.NONE;
  31.         this.ammo = 0;
  32.     }
  33.    
  34.     public Weapon(WeaponData wd)
  35.     {
  36.         if(wd == null)
  37.         {
  38.             this.model = WeaponModel.NONE;
  39.             this.ammo = 0;
  40.         }
  41.         else
  42.         {
  43.             this.model = wd.getModel();
  44.             this.ammo = wd.getAmmo();
  45.         }
  46.     }
  47.    
  48.     public int getID()
  49.     {
  50.         return getIDByWeaponModel(this.model);
  51.     }
  52.    
  53.     public static int getIDByWeaponModel(WeaponModel wm)
  54.     {
  55.         return (wm == null)?0:wm.compareTo(WeaponModel.NONE);
  56.     }
  57.    
  58.     public WEAPON_SLOT getSlot()
  59.     {
  60.         return getSlotByWeaponModel(this.model);
  61.     }
  62.    
  63.     public static WEAPON_SLOT getSlotByWeaponModel(WeaponModel wm)
  64.     {
  65.         WEAPON_SLOT ret;
  66.         if(wm == null) ret = WEAPON_SLOT.INVALID;
  67.         else
  68.         {
  69.             switch(wm)
  70.             {
  71.             case GOLFCLUB: case NITESTICK: case KNIFE: case BAT: case SHOVEL: case POOLSTICK: case KATANA: case CHAINSAW:
  72.                 ret = WEAPON_SLOT.MELEE;
  73.                 break;
  74.             case COLT45: case SILENCED_COLT45: case DEAGLE:
  75.                 ret = WEAPON_SLOT.PISTOL;
  76.                 break;
  77.             case SHOTGUN: case SAWEDOFF: case SHOTGSPA:
  78.                 ret = WEAPON_SLOT.SHOTGUN;
  79.                 break;
  80.             case UZI: case MP5: case TEC9:
  81.                 ret = WEAPON_SLOT.MACHINE_PISTOL;
  82.                 break;
  83.             case AK47: case M4:
  84.                 ret = WEAPON_SLOT.CARABINER;
  85.                 break;
  86.             case RIFLE: case SNIPER:
  87.                 ret = WEAPON_SLOT.RIFLE;
  88.                 break;
  89.             case ROCKETLAUNCHER: case HEATSEEKER: case FLAMETHROWER: case MINIGUN:
  90.                 ret = WEAPON_SLOT.HEAVY;
  91.                 break;
  92.             case GRENADE: case TEARGAS: case MOLTOV: case SATCHEL:
  93.                 ret = WEAPON_SLOT.THROWABLE;
  94.                 break;
  95.             case SPRAYCAN: case FIREEXTINGUISHER: case CAMERA:
  96.                 ret = WEAPON_SLOT.MISC1;
  97.             case DILDO: case DILDO2: case VIBRATOR: case VIBRATOR2: case FLOWER: case CANE:
  98.                 ret = WEAPON_SLOT.MISC2;
  99.             case NIGHTVISION: case INFRARED: case PARACHUTE:
  100.                 ret = WEAPON_SLOT.WEARABLE;
  101.                 break;
  102.             case BOMB:
  103.                 ret = WEAPON_SLOT.DETONATOR;
  104.                 break;
  105.             default:
  106.                 ret = WEAPON_SLOT.HAND;
  107.                 break;
  108.             }
  109.         }
  110.         return ret;
  111.     }
  112.    
  113.     public int getSlotID()
  114.     {
  115.         return getSlotIDByWeaponModel(this.model);
  116.     }
  117.    
  118.     public static int getSlotIDByWeaponModel(WeaponModel wm)
  119.     {
  120.         return getSlotByWeaponModel(wm).compareTo(WEAPON_SLOT.HAND);
  121.     }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement