Thread: Butterfly/Impling Hunting

Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1 Butterfly/Impling Hunting 
    Banned

    Join Date
    Apr 2012
    Age
    27
    Posts
    2,936
    Thanks given
    1,126
    Thanks received
    1,081
    Rep Power
    0
    This includes the magic butterfly net giving an extra amount of XP.

    Yes, I know the naming is conventionally incorrect I made this months ago, and CBA to fix it.

    Code:
    package game.skill.Hunter;
    
    import java.util.HashMap;
    
    import engine.util.Misc;
    import game.Client;
    import game.npc.NPCHandler;
    
    public class Implings {
    	
    	/**
    	 * Handles all data for the implings
    	 * @author Ochroid | Scott
    	 */
    	
    	private static enum Imps {
    		
    		BABY_IMPLING(1028, 17, 25, 11238),
    		YOUNG_IMPLING(1029, 22, 65, 11240),
    		GOURMET_IMPLING(1030, 28, 113, 11242),
    		EARTH_IMPLING(1031, 36, 177, 11244),
    		ESSENCE_IMPLING(1032, 42, 255, 11246),
    		ECLECTIC_IMPLING(1033, 50, 289, 11248),
    		NATURE_IMPLING(1034, 58, 353, 11250),
    		MAGPIE_IMPLING(1035, 65, 409, 11252),
    		NINJA_IMPLING(6063, 74, 481, 11254),
    		DRAGON_IMPLING(6064, 83, 553, 11256);
    		
    		private int impId, level, xp, jar;
    		
    		private Imps(final int impId, final int level, final int xp, final int jar) {
    			this.impId = impId;
    			this.level = level;
    			this.xp = xp;
    			this.jar = jar;
    		}
    		
    		private int getImpID() {
    			return impId;
    		}
    		
    		private int getLevel() {
    			return level;
    		}
    		
    		private int getXP() {
    			return xp * 20;
    		}
    		
    		private int getJar() {
    			return jar;
    		}
    		
    		private String getName() {
    			return Misc.optimizeText(toString().toLowerCase().replaceAll("_", " "));
    		}
    		
    		public static HashMap<Integer, Imps> implings = new HashMap<Integer, Imps>();
    
    		static {
    			for (final Imps impling : Imps.values()) {
    				Imps.implings.put(impling.getImpID(), impling);
    			}
    		}
    		
    	}
    	
    	/**
    	 * Checks if player can catch an imp
    	 * @param c Client
    	 * @param ID NPC Being clicked on
    	 * @return Returns whether or not player can catch the imp
    	 */
    	private static boolean canCatch(final Client c, final int ID, final int impId) {
    		Imps i = Imps.implings.get(impId);
    		if(i == null) {
    			return false;
    		}
    		if (System.currentTimeMillis() - c.lastThieve < 2000) {
    			return false;
    		}
    		c.lastThieve = System.currentTimeMillis();
    		if(i.getLevel() > c.getLevelForXP(c.playerXP[Constants.HUNTER])) {
    			c.sendMessage("You need a hunter level of at least "+i.getLevel()+" to catch this impling.");
    			return false;
    		}
    		if(!Constants.hasRegularNet(c) && !Constants.hasMagicNet(c)) {
    			c.sendMessage("You must have a butterfly net wielded in order to catch an imp.");
    			return false;
    		}
    		if(Constants.hasMagicNet(c) && c.getItems().freeSlots() <= 0) {
    			c.sendMessage("You must have at least 1 free slot when catching an imp with that net!");
    			return false;
    		}
    		if(!c.getItems().playerHasItem(Constants.JAR) && !Constants.hasMagicNet(c)) {
    			c.sendMessage("You must have at least 1 impling jar with you, in order to catch an imp.");
    			return false;
    		}
    		return true;
    	}
    	
    	/**
    	 * Handles the actual catching
    	 * @param c Client
    	 * @param ID Npc being clicked
    	 */
    	
    	public static void catchImp(final Client c, final int ID, final int impId) {
    		Imps i = Imps.implings.get(impId);
    		if(i == null) {
    			return;
    		}
    		if(!canCatch(c, ID, impId)) {
    			return;
    		}
    		if (Misc.random(10) >= ((c.playerLevel[Constants.HUNTER] - 10) / 10) + 1) {
                c.sendMessage("You fail catching the "+i.getName()+"!");
                return;
            }
    		if(NPCHandler.npcs[ID].isDead) {
    			return;
    		}
    		c.getItems().deleteItem(Constants.JAR, Constants.hasMagicNet(c) ? 0 : 1);
    		c.getItems().addItem(i.getJar(), 1);
    		c.getPA().addSkillXP(Constants.hasMagicNet(c) ? i.getXP() * 2 : i.getXP(), Constants.HUNTER);
    		c.startAnimation(6999);
            NPCHandler.npcs[ID].isDead = true;
            NPCHandler.npcs[ID].updateRequired = true;
            c.sendMessage("You catch the "+i.getName()+"!");
    	}
    	
    	/**
    	 * Impling Loot Handling Below
    	 */
    	
    	private final static int[] babyLoots = {995, 113, 1742, 1208, 5293, 1437, 313, 314, 1335};
    	private final static int[] babyAmount = {275, 1, 4, 1, 3, 12, 7, 11, 1};
    	
    	private final static int[] youngLoots = {995, 2349, 1605, 1522, 526, 1177, 556, 227, 225};
    	private final static int[] youngAmount = {450, 1, 3, 8, 1, 1, 17, 1, 1};
    	
    	private final static int[] gormLoots = {995, 316, 323, 333, 352, 361, 373};
    	private final static int[] gormAmount = {630, 5, 1, 1, 3, 1, 1};
    
    	private final static int[] earthLoots = {995, 1520, 5293, 1605, 133, 557, 1440, 1119};
    	private final static int[] earthAmount = {850, 3, 6, 1, 1, 50, 1, 1};
    	
    	private final static int[] essLoots = {995, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566};
    	private final static int[] essAmount = {1125, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 10};
    	
    	private final static int[] eclecticLoots = {995, 1617, 1734, 207, 2442, 1726};
    	private final static int[] eclecticAmount = {1350, 1, 45, 1, 1, 2};
    	
    	private final static int[] natureLoots = {995, 7945, 1462, 561, 444, 1065, 1381};
    	private final static int[] natureAmount = {1755, 5, 1, 11, 1, 1, 1};
    	
    	private final static int[] magpieLoots = {995, 1712, 892, 861, 1215, 1428, 2437};
    	private final static int[] magpieAmount = {2016, 1, 45, 1, 1, 1, 3};
    	
    	private final static int[] ninjaLoots = {995, 2481, 5300, 1334, 44, 53, 1085};
    	private final static int[] ninjaAmount = {2733, 1, 2, 2, 20, 40, 1};
    	
    	private final static int[] dragonLoots = {995, 4587, 1377, 11237, 11237, 1434, 1616, 4131, 452, 9244};
    	private final static int[] dragonAmount = {4267, 1, 1, 25, 17, 1, 5, 1, 15, 50};
    	
    	/**
    	 * Handles looting for baby implings
    	 * @param c Client
    	 * @param jar Imp Jar
    	 */
    	
    	public static void lootJar(final Client c, final int jar) {
    		int loot = 0;
    		int[] type = null;
    		int[] amount = null;
    		if(!c.getItems().playerHasItem(jar)) {
    			return;
    		}
    		if(c.getItems().freeSlots() < 1) {
    			c.sendMessage("You must have at least 1 inventory slots open, when looting an impling.");
    			return;
    		}
    		c.getItems().deleteItem(jar, 1);
    		switch(jar) {
    			case 11238:
    				loot = (int) (Misc.random(babyLoots.length - 1));
    				type = babyLoots;
    				amount = babyAmount;
    				break;
    			case 11240:
    				loot = (int) (Misc.random(youngLoots.length - 1));
    				type = youngLoots;
    				amount = youngAmount;
    				break;
    			case 11242:
    				loot = (int) (Misc.random(gormLoots.length - 1));
    				type = gormLoots;
    				amount = gormAmount;
    				break;
    			case 11244:
    				loot = (int) (Misc.random(earthLoots.length - 1));
    				type = earthLoots;
    				amount = earthAmount;
    				break;
    			case 11246:
    				loot = (int) (Misc.random(essLoots.length - 1));
    				type = essLoots;
    				amount = essAmount;
    				break;
    			case 11248:
    				loot = (int) (Misc.random(eclecticLoots.length - 1));
    				type = eclecticLoots;
    				amount = eclecticAmount;
    				break;
    			case 11250:
    				loot = (int) (Misc.random(natureLoots.length - 1));
    				type = natureLoots;
    				amount = natureAmount;
    				break;
    			case 11252:
    				loot = (int) (Misc.random(magpieLoots.length - 1));
    				type = magpieLoots;
    				amount = magpieAmount;
    				break;
    			case 11254:
    				loot = (int) (Misc.random(ninjaLoots.length - 1));
    				type = ninjaLoots;
    				amount = ninjaAmount;
    				break;
    			case 11256:
    				loot = (int) (Misc.random(dragonLoots.length - 1));
    				type = dragonLoots;
    				amount = dragonAmount;
    				break;
    		}
    		c.getItems().addItem(type[loot], amount[loot]);
    		if(Constants.breakJar(c)) {
    			c.sendMessage("The impling jar shatters as you try to loot it.");
    			return;
    		}
    		c.getItems().addItem(Constants.JAR, 1);
    	}
    
    }
    Code:
    package game.skill.Hunter;
    
    import engine.util.Misc;
    
    import game.Client;
    /**
     * @author Ochroid | Scott
     */
    final class Constants {
    
    	/**
    	 * Variable Declaration
    	 */
    	protected static final int HUNTER = 21, JAR = 11260, BUTTERFLY_NET = 10010, MAGIC_NET = 11259, 
    		BUTTERFLY_JAR = 10012, NPCID = 0, OBJECTID = 1, CATCHID = 2, ANIM = 3, ITEMID = 4, LAYANIM = 5, 
    		XP = 6, LOOT = 7, REQ = 8, BAIT = 9, ORIG = 10, TREE = 11;
    	
    	/**
    	 * Checks if player has the magic buttefly net
    	 * @param c Client
    	 * @return Returns whether or not the player has the net
    	 */
    	protected static boolean hasMagicNet(final Client c) {
    		return c.playerEquipment[c.playerWeapon] == Constants.MAGIC_NET;
    	}
    	
    	/**
    	 * Checks if player has a regular butterfly net
    	 * @param c Client
    	 * @return 
    	 */
    	protected static boolean hasRegularNet(final Client c) {
    		return c.playerEquipment[c.playerWeapon] == Constants.BUTTERFLY_NET;
    	}
    	
    	/**
    	 * Checks if jar will break
    	 * @param c Client
    	 * @return Wether or not the jar will break
    	 */
    	protected static boolean breakJar(final Client c) {
    		return Misc.random(7) == 0;
    	}
    
    }
    Code:
    package game.skill.Hunter;
    
    import java.util.HashMap;
    
    import engine.util.Misc;
    import game.Client;
    import game.npc.NPCHandler;
    
    public class ButterflyCatching {
    
    	/**
    	 * Butterfly Catching
    	 * @author Scott | Ochroid
    	 * Data for butterflys
    	 */
    
    	private static enum Butterfly {
    
    		RUBY_HARVEST(5085, 1, 10, 10020),
    		SAPPHIRE_GLACIALIS(5084, 25, 25, 10018),
    		SNOWY_KNIGHT(5083, 50, 75, 10016),
    		BLACK_WARLOCK(5082, 75, 250, 10014);
    
    		private int butterfly, level, xp, jar;
    
    		private Butterfly(final int butterfly, final int level, final int xp, final int jar) {
    			this.butterfly = butterfly;
    			this.level = level;
    			this.xp = xp;
    			this.jar = jar;
    		}
    
    		private int getButterfly() {
    			return butterfly;
    		}
    
    		private int getLevel() {
    			return level;
    		}
    
    		private int getXP() {
    			return xp * 20;
    		}
    
    		private int getJar() {
    			return jar;
    		}
    		
    		private String getName() {
    			return Misc.optimizeText(toString().toLowerCase().replaceAll("_", " "));
    		}
    
    		public static HashMap<Integer, Butterfly> butterflys = new HashMap<Integer, Butterfly>();
    
    		static {
    			for (final Butterfly b : Butterfly.values()) {
    				Butterfly.butterflys.put(b.getButterfly(), b);
    			}
    		}
    
    	}
    	
    	/**
    	 * Checks if player can catch an imp
    	 * @param c Client
    	 * @param ID NPC Being clicked on
    	 * @return Returns whether or not player can catch the imp
    	 */
    	
    	private static boolean canCatch(final Client c, final int ID, final int butterflyId) {
    		Butterfly b = Butterfly.butterflys.get(butterflyId);
    		if(b == null) {
    			return false;
    		}
    		if (System.currentTimeMillis() - c.hunterDelay < 2000) {
    			return false;
    		}
    		c.hunterDelay = System.currentTimeMillis();
    		if(b.getLevel() > c.getLevelForXP(c.playerXP[Constants.HUNTER])) {
    			c.sendMessage("You need a hunter level of at least "+b.getLevel()+" to catch this butterfly.");
    			return false;
    		}
    		if(!Constants.hasRegularNet(c) && !Constants.hasMagicNet(c)) {
    			c.sendMessage("You must have a butterfly net wielded in order to catch a butterfly.");
    			return false;
    		}
    		if(Constants.hasMagicNet(c) && c.getItems().freeSlots() <= 0) {
    			c.sendMessage("You must have at least 1 free slot when catching a butterfly with that net!");
    			return false;
    		}
    		if(!c.getItems().playerHasItem(Constants.BUTTERFLY_JAR) && !Constants.hasMagicNet(c)) {
    			c.sendMessage("You must have at least 1 butterfly jar with you, in order to catch a butterfly.");
    			return false;
    		}
    		return true;
    	}
    	
    	/**
    	 * Handles the actual catching
    	 * @param c Client
    	 * @param ID Npc being clicked
    	 * @param butterfly Butterfly id
    	 */
    	
    	public static void catchButterfly(final Client c, final int ID, final int butterflyId) {
    		Butterfly b = Butterfly.butterflys.get(butterflyId);
    		if(b == null) {
    			return;
    		}
    		if(!canCatch(c, ID, butterflyId)) {
    			return;
    		}
    		if (Misc.random(10) >= ((c.playerLevel[Constants.HUNTER] - 10) / 10) + 1) {
                c.sendMessage("You fail catching the "+b.getName()+"!");
                return;
            }
    		if(NPCHandler.npcs[ID].isDead) {
    			return;
    		}
    		c.getItems().deleteItem(Constants.BUTTERFLY_JAR, Constants.hasMagicNet(c) ? 0 : 1);
    		c.getItems().addItem(b.getJar(), 1);
    		c.getPA().addSkillXP(Constants.hasMagicNet(c) ? b.getXP() * 2 : b.getXP(), Constants.HUNTER);
    		c.startAnimation(6999);
            NPCHandler.npcs[ID].isDead = true;
            NPCHandler.npcs[ID].updateRequired = true;
            c.sendMessage("You catch the "+b.getName()+"!");
    	}
    	
    	/**
    	 * Handles the release of the butterfly
    	 * @param c Client
    	 * @param jar Jar ID
    	 */
    	
    	public static void releaseButterfly(final Client c, final int jar) {
    		if(!c.getItems().playerHasItem(jar)) {
    			return;
    		}
    		c.getItems().deleteItem2(jar, 1);
    		if(Constants.breakJar(c)) {
    			c.sendMessage("The butterfly jar shatters as you release the creature inside!");
    			return;
    		}
    		c.getItems().addItem(Constants.BUTTERFLY_JAR, 1);
    	}
    	
    }
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member
    Join Date
    Dec 2011
    Posts
    0
    Thanks given
    87
    Thanks received
    74
    Rep Power
    0
    Cool


    Quote Originally Posted by Stevie View Post
    I know but there is like 5 servers with deadlypkers's source. it's being passed around like the school's whore.
    Quote Originally Posted by King J Scape View Post
    Not everything in life can be pretty, look at your self for an example.
    Have a nice day.
    [Spoil][/Spoil]
    Reply With Quote  
     

  4. Thankful users:


  5. #3  
    Registered Member

    Join Date
    Oct 2011
    Age
    28
    Posts
    1,880
    Thanks given
    311
    Thanks received
    557
    Rep Power
    703
    ty scott, gonna use
    Reply With Quote  
     

  6. #4  
    GooRoo
    Guest
    Now I want your hunter class. Great release Scott.
    Reply With Quote  
     

  7. #5  



    Join Date
    Oct 2011
    Posts
    874
    Thanks given
    301
    Thanks received
    373
    Rep Power
    338
    Very nice and clean release. Thanks for the contribution.
    Reply With Quote  
     

  8. #6  
    Banned

    Join Date
    Jun 2010
    Age
    36
    Posts
    4,335
    Thanks given
    4
    Thanks received
    274
    Rep Power
    0
    Quote Originally Posted by Scott* View Post
    This includes the magic butterfly net giving an extra amount of XP.

    Code:
    package game.skill.Hunter;
    
    import java.util.HashMap;
    
    import engine.util.Misc;
    import game.Client;
    import game.npc.NPCHandler;
    
    public class Implings {
    	
    	/**
    	 * Handles all data for the implings
    	 * @author Ochroid | Scott
    	 */
    	
    	private static enum Imps {
    		
    		BABY_IMPLING(1028, 17, 25, 11238),
    		YOUNG_IMPLING(1029, 22, 65, 11240),
    		GOURMET_IMPLING(1030, 28, 113, 11242),
    		EARTH_IMPLING(1031, 36, 177, 11244),
    		ESSENCE_IMPLING(1032, 42, 255, 11246),
    		ECLECTIC_IMPLING(1033, 50, 289, 11248),
    		NATURE_IMPLING(1034, 58, 353, 11250),
    		MAGPIE_IMPLING(1035, 65, 409, 11252),
    		NINJA_IMPLING(6063, 74, 481, 11254),
    		DRAGON_IMPLING(6064, 83, 553, 11256);
    		
    		private int impId, level, xp, jar;
    		
    		private Imps(final int impId, final int level, final int xp, final int jar) {
    			this.impId = impId;
    			this.level = level;
    			this.xp = xp;
    			this.jar = jar;
    		}
    		
    		private int getImpID() {
    			return impId;
    		}
    		
    		private int getLevel() {
    			return level;
    		}
    		
    		private int getXP() {
    			return xp * 20;
    		}
    		
    		private int getJar() {
    			return jar;
    		}
    		
    		private String getName() {
    			return Misc.optimizeText(toString().toLowerCase().replaceAll("_", " "));
    		}
    		
    		public static HashMap<Integer, Imps> implings = new HashMap<Integer, Imps>();
    
    		static {
    			for (final Imps impling : Imps.values()) {
    				Imps.implings.put(impling.getImpID(), impling);
    			}
    		}
    		
    	}
    	
    	/**
    	 * Checks if player can catch an imp
    	 * @param c Client
    	 * @param ID NPC Being clicked on
    	 * @return Returns whether or not player can catch the imp
    	 */
    	private static boolean canCatch(final Client c, final int ID, final int impId) {
    		Imps i = Imps.implings.get(impId);
    		if(i == null) {
    			return false;
    		}
    		if (System.currentTimeMillis() - c.lastThieve < 2000) {
    			return false;
    		}
    		c.lastThieve = System.currentTimeMillis();
    		if(i.getLevel() > c.getLevelForXP(c.playerXP[Constants.HUNTER])) {
    			c.sendMessage("You need a hunter level of at least "+i.getLevel()+" to catch this impling.");
    			return false;
    		}
    		if(!Constants.hasRegularNet(c) && !Constants.hasMagicNet(c)) {
    			c.sendMessage("You must have a butterfly net wielded in order to catch an imp.");
    			return false;
    		}
    		if(Constants.hasMagicNet(c) && c.getItems().freeSlots() <= 0) {
    			c.sendMessage("You must have at least 1 free slot when catching an imp with that net!");
    			return false;
    		}
    		if(!c.getItems().playerHasItem(Constants.JAR) && !Constants.hasMagicNet(c)) {
    			c.sendMessage("You must have at least 1 impling jar with you, in order to catch an imp.");
    			return false;
    		}
    		return true;
    	}
    	
    	/**
    	 * Handles the actual catching
    	 * @param c Client
    	 * @param ID Npc being clicked
    	 */
    	
    	public static void catchImp(final Client c, final int ID, final int impId) {
    		Imps i = Imps.implings.get(impId);
    		if(i == null) {
    			return;
    		}
    		if(!canCatch(c, ID, impId)) {
    			return;
    		}
    		if (Misc.random(10) >= ((c.playerLevel[Constants.HUNTER] - 10) / 10) + 1) {
                c.sendMessage("You fail catching the "+i.getName()+"!");
                return;
            }
    		if(NPCHandler.npcs[ID].isDead) {
    			return;
    		}
    		c.getItems().deleteItem(Constants.JAR, Constants.hasMagicNet(c) ? 0 : 1);
    		c.getItems().addItem(i.getJar(), 1);
    		c.getPA().addSkillXP(Constants.hasMagicNet(c) ? i.getXP() * 2 : i.getXP(), Constants.HUNTER);
    		c.startAnimation(6999);
            NPCHandler.npcs[ID].isDead = true;
            NPCHandler.npcs[ID].updateRequired = true;
            c.sendMessage("You catch the "+i.getName()+"!");
    	}
    	
    	/**
    	 * Impling Loot Handling Below
    	 */
    	
    	private final static int[] babyLoots = {995, 113, 1742, 1208, 5293, 1437, 313, 314, 1335};
    	private final static int[] babyAmount = {275, 1, 4, 1, 3, 12, 7, 11, 1};
    	
    	private final static int[] youngLoots = {995, 2349, 1605, 1522, 526, 1177, 556, 227, 225};
    	private final static int[] youngAmount = {450, 1, 3, 8, 1, 1, 17, 1, 1};
    	
    	private final static int[] gormLoots = {995, 316, 323, 333, 352, 361, 373};
    	private final static int[] gormAmount = {630, 5, 1, 1, 3, 1, 1};
    
    	private final static int[] earthLoots = {995, 1520, 5293, 1605, 133, 557, 1440, 1119};
    	private final static int[] earthAmount = {850, 3, 6, 1, 1, 50, 1, 1};
    	
    	private final static int[] essLoots = {995, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566};
    	private final static int[] essAmount = {1125, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 10};
    	
    	private final static int[] eclecticLoots = {995, 1617, 1734, 207, 2442, 1726};
    	private final static int[] eclecticAmount = {1350, 1, 45, 1, 1, 2};
    	
    	private final static int[] natureLoots = {995, 7945, 1462, 561, 444, 1065, 1381};
    	private final static int[] natureAmount = {1755, 5, 1, 11, 1, 1, 1};
    	
    	private final static int[] magpieLoots = {995, 1712, 892, 861, 1215, 1428, 2437};
    	private final static int[] magpieAmount = {2016, 1, 45, 1, 1, 1, 3};
    	
    	private final static int[] ninjaLoots = {995, 2481, 5300, 1334, 44, 53, 1085};
    	private final static int[] ninjaAmount = {2733, 1, 2, 2, 20, 40, 1};
    	
    	private final static int[] dragonLoots = {995, 4587, 1377, 11237, 11237, 1434, 1616, 4131, 452, 9244};
    	private final static int[] dragonAmount = {4267, 1, 1, 25, 17, 1, 5, 1, 15, 50};
    	
    	/**
    	 * Handles looting for baby implings
    	 * @param c Client
    	 * @param jar Imp Jar
    	 */
    	
    	public static void lootJar(final Client c, final int jar) {
    		int loot = 0;
    		int[] type = null;
    		int[] amount = null;
    		if(!c.getItems().playerHasItem(jar)) {
    			return;
    		}
    		if(c.getItems().freeSlots() < 1) {
    			c.sendMessage("You must have at least 1 inventory slots open, when looting an impling.");
    			return;
    		}
    		c.getItems().deleteItem(jar, 1);
    		switch(jar) {
    			case 11238:
    				loot = (int) (Misc.random(babyLoots.length - 1));
    				type = babyLoots;
    				amount = babyAmount;
    				break;
    			case 11240:
    				loot = (int) (Misc.random(youngLoots.length - 1));
    				type = youngLoots;
    				amount = youngAmount;
    				break;
    			case 11242:
    				loot = (int) (Misc.random(gormLoots.length - 1));
    				type = gormLoots;
    				amount = gormAmount;
    				break;
    			case 11244:
    				loot = (int) (Misc.random(earthLoots.length - 1));
    				type = earthLoots;
    				amount = earthAmount;
    				break;
    			case 11246:
    				loot = (int) (Misc.random(essLoots.length - 1));
    				type = essLoots;
    				amount = essAmount;
    				break;
    			case 11248:
    				loot = (int) (Misc.random(eclecticLoots.length - 1));
    				type = eclecticLoots;
    				amount = eclecticAmount;
    				break;
    			case 11250:
    				loot = (int) (Misc.random(natureLoots.length - 1));
    				type = natureLoots;
    				amount = natureAmount;
    				break;
    			case 11252:
    				loot = (int) (Misc.random(magpieLoots.length - 1));
    				type = magpieLoots;
    				amount = magpieAmount;
    				break;
    			case 11254:
    				loot = (int) (Misc.random(ninjaLoots.length - 1));
    				type = ninjaLoots;
    				amount = ninjaAmount;
    				break;
    			case 11256:
    				loot = (int) (Misc.random(dragonLoots.length - 1));
    				type = dragonLoots;
    				amount = dragonAmount;
    				break;
    		}
    		c.getItems().addItem(type[loot], amount[loot]);
    		if(Constants.breakJar(c)) {
    			c.sendMessage("The impling jar shatters as you try to loot it.");
    			return;
    		}
    		c.getItems().addItem(Constants.JAR, 1);
    	}
    
    }
    Code:
    package game.skill.Hunter;
    
    import engine.util.Misc;
    
    import game.Client;
    /**
     * @author Ochroid | Scott
     */
    final class Constants {
    
    	/**
    	 * Variable Declaration
    	 */
    	protected static final int HUNTER = 21, JAR = 11260, BUTTERFLY_NET = 10010, MAGIC_NET = 11259, 
    		BUTTERFLY_JAR = 10012, NPCID = 0, OBJECTID = 1, CATCHID = 2, ANIM = 3, ITEMID = 4, LAYANIM = 5, 
    		XP = 6, LOOT = 7, REQ = 8, BAIT = 9, ORIG = 10, TREE = 11;
    	
    	/**
    	 * Checks if player has the magic buttefly net
    	 * @param c Client
    	 * @return Returns whether or not the player has the net
    	 */
    	protected static boolean hasMagicNet(final Client c) {
    		return c.playerEquipment[c.playerWeapon] == Constants.MAGIC_NET;
    	}
    	
    	/**
    	 * Checks if player has a regular butterfly net
    	 * @param c Client
    	 * @return 
    	 */
    	protected static boolean hasRegularNet(final Client c) {
    		return c.playerEquipment[c.playerWeapon] == Constants.BUTTERFLY_NET;
    	}
    	
    	/**
    	 * Checks if jar will break
    	 * @param c Client
    	 * @return Wether or not the jar will break
    	 */
    	protected static boolean breakJar(final Client c) {
    		return Misc.random(7) == 0;
    	}
    
    }
    Code:
    package game.skill.Hunter;
    
    import java.util.HashMap;
    
    import engine.util.Misc;
    import game.Client;
    import game.npc.NPCHandler;
    
    public class ButterflyCatching {
    
    	/**
    	 * Butterfly Catching
    	 * @author Scott | Ochroid
    	 * Data for butterflys
    	 */
    
    	private static enum Butterfly {
    
    		RUBY_HARVEST(5085, 1, 10, 10020),
    		SAPPHIRE_GLACIALIS(5084, 25, 25, 10018),
    		SNOWY_KNIGHT(5083, 50, 75, 10016),
    		BLACK_WARLOCK(5082, 75, 250, 10014);
    
    		private int butterfly, level, xp, jar;
    
    		private Butterfly(final int butterfly, final int level, final int xp, final int jar) {
    			this.butterfly = butterfly;
    			this.level = level;
    			this.xp = xp;
    			this.jar = jar;
    		}
    
    		private int getButterfly() {
    			return butterfly;
    		}
    
    		private int getLevel() {
    			return level;
    		}
    
    		private int getXP() {
    			return xp * 20;
    		}
    
    		private int getJar() {
    			return jar;
    		}
    		
    		private String getName() {
    			return Misc.optimizeText(toString().toLowerCase().replaceAll("_", " "));
    		}
    
    		public static HashMap<Integer, Butterfly> butterflys = new HashMap<Integer, Butterfly>();
    
    		static {
    			for (final Butterfly b : Butterfly.values()) {
    				Butterfly.butterflys.put(b.getButterfly(), b);
    			}
    		}
    
    	}
    	
    	/**
    	 * Checks if player can catch an imp
    	 * @param c Client
    	 * @param ID NPC Being clicked on
    	 * @return Returns whether or not player can catch the imp
    	 */
    	
    	private static boolean canCatch(final Client c, final int ID, final int butterflyId) {
    		Butterfly b = Butterfly.butterflys.get(butterflyId);
    		if(b == null) {
    			return false;
    		}
    		if (System.currentTimeMillis() - c.hunterDelay < 2000) {
    			return false;
    		}
    		c.hunterDelay = System.currentTimeMillis();
    		if(b.getLevel() > c.getLevelForXP(c.playerXP[Constants.HUNTER])) {
    			c.sendMessage("You need a hunter level of at least "+b.getLevel()+" to catch this butterfly.");
    			return false;
    		}
    		if(!Constants.hasRegularNet(c) && !Constants.hasMagicNet(c)) {
    			c.sendMessage("You must have a butterfly net wielded in order to catch a butterfly.");
    			return false;
    		}
    		if(Constants.hasMagicNet(c) && c.getItems().freeSlots() <= 0) {
    			c.sendMessage("You must have at least 1 free slot when catching a butterfly with that net!");
    			return false;
    		}
    		if(!c.getItems().playerHasItem(Constants.BUTTERFLY_JAR) && !Constants.hasMagicNet(c)) {
    			c.sendMessage("You must have at least 1 butterfly jar with you, in order to catch a butterfly.");
    			return false;
    		}
    		return true;
    	}
    	
    	/**
    	 * Handles the actual catching
    	 * @param c Client
    	 * @param ID Npc being clicked
    	 * @param butterfly Butterfly id
    	 */
    	
    	public static void catchButterfly(final Client c, final int ID, final int butterflyId) {
    		Butterfly b = Butterfly.butterflys.get(butterflyId);
    		if(b == null) {
    			return;
    		}
    		if(!canCatch(c, ID, butterflyId)) {
    			return;
    		}
    		if (Misc.random(10) >= ((c.playerLevel[Constants.HUNTER] - 10) / 10) + 1) {
                c.sendMessage("You fail catching the "+b.getName()+"!");
                return;
            }
    		if(NPCHandler.npcs[ID].isDead) {
    			return;
    		}
    		c.getItems().deleteItem(Constants.BUTTERFLY_JAR, Constants.hasMagicNet(c) ? 0 : 1);
    		c.getItems().addItem(b.getJar(), 1);
    		c.getPA().addSkillXP(Constants.hasMagicNet(c) ? b.getXP() * 2 : b.getXP(), Constants.HUNTER);
    		c.startAnimation(6999);
            NPCHandler.npcs[ID].isDead = true;
            NPCHandler.npcs[ID].updateRequired = true;
            c.sendMessage("You catch the "+b.getName()+"!");
    	}
    	
    	/**
    	 * Handles the release of the butterfly
    	 * @param c Client
    	 * @param jar Jar ID
    	 */
    	
    	public static void releaseButterfly(final Client c, final int jar) {
    		if(!c.getItems().playerHasItem(jar)) {
    			return;
    		}
    		c.getItems().deleteItem2(jar, 1);
    		if(Constants.breakJar(c)) {
    			c.sendMessage("The butterfly jar shatters as you release the creature inside!");
    			return;
    		}
    		c.getItems().addItem(Constants.BUTTERFLY_JAR, 1);
    	}
    	
    }
    Great release might use !
    Reply With Quote  
     

  9. #7  
    Registered Member OptimusHaley's Avatar
    Join Date
    Sep 2012
    Posts
    132
    Thanks given
    16
    Thanks received
    5
    Rep Power
    11
    Dang. Nice Scott! I might use it. But do you plan on releasing other stuff from your server? Since you put it down or just this?
    Reply With Quote  
     

  10. #8  
    Banned

    Join Date
    Apr 2012
    Age
    27
    Posts
    2,936
    Thanks given
    1,126
    Thanks received
    1,081
    Rep Power
    0
    Quote Originally Posted by OptimusHaley View Post
    Dang. Nice Scott! I might use it. But do you plan on releasing other stuff from your server? Since you put it down or just this?
    Minuscule stuff if that.
    Reply With Quote  
     

  11. #9  
    Registered Member blood rush20's Avatar
    Join Date
    Sep 2008
    Posts
    426
    Thanks given
    18
    Thanks received
    9
    Rep Power
    7
    Enjoyed the clean coding, a eye refresher compared to most. Great job Scott* !
    Reply With Quote  
     

  12. Thankful user:


  13. #10  
    Spread Love

    Dhruv's Avatar
    Join Date
    Feb 2012
    Age
    28
    Posts
    1,011
    Thanks given
    157
    Thanks received
    167
    Rep Power
    215
    Ooo very nice. Good job
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Butterfly
    By Achtryn in forum Literature & Language Arts
    Replies: 3
    Last Post: 03-22-2012, 10:25 PM
  2. [req] impling\butterfly jar model ids
    By Ash Ketchum in forum Models
    Replies: 2
    Last Post: 03-06-2012, 01:32 AM
  3. RuneScape-Like Impling Hunting
    By Akinz in forum Show-off
    Replies: 15
    Last Post: 09-28-2011, 11:25 AM
  4. Replies: 17
    Last Post: 08-05-2010, 06:37 AM
  5. Butterfly
    By infallible in forum Showcase
    Replies: 7
    Last Post: 05-11-2008, 05:19 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •