Thread: Farming

Results 1 to 2 of 2
  1. #1 Farming 
    Donator
    ExoriaRSPS's Avatar
    Join Date
    Apr 2022
    Posts
    14
    Thanks given
    0
    Thanks received
    5
    Rep Power
    36
    My version of Farming I wrote a long ass time ago.

    Farming.java
    Code:
    package com.exoria.game.player.actions;
    
    import com.exoria.cache.loaders.ItemDefinitions;
    import com.exoria.game.Animation;
    import com.exoria.game.player.Player;
    import com.exoria.game.player.Skills;
    import com.exoria.utils.Utils;
    
    /**
     * 
     * @author Aksel
     * 
     * @since 9/7/2013
     * @updated 9/13/2013 - Lowered snapdragon xp
     * 
     */
    
    public class Farming extends Action {
    
    	public enum Seed {
    		GUAP(5291, 199, 1, 2.5), 
    		MARRENTILL(5292, 201, 5, 5), 
    		TARROMIN(5293, 203, 11, 7.5),
    		HARRALANDER(5294, 205, 20, 10), 
    		RANARR(5295, 207, 25, 15), 
    		TOADFLAX(5296, 3049, 30, 25),
    		IRIT(5297, 209, 40, 27.5), 
    		AVANTOE(5298, 211, 48, 30), 
    		KWUARM(5299, 213, 54, 35),
    		SNAPDRAGON(5300, 3051, 59, 32), 
    		CADENTINE(5301, 215, 65, 40), 
    		LANTADYME(5302, 2485, 67, 45),
    		DWARFWEED(5303, 217, 70, 47.5), 
    		FELLSTALK(21621, 21626, 91, 70), 
    		TORSTOL(5304, 219, 75, 75);
    
    		private int id, product, level;
    		private double xp;
    
    		private Seed(int id, int product, int level, double xp) {
    			this.id = id;
    			this.product = product;
    			this.level = level;
    			this.xp = xp;
    		}
    
    		public int getId() {
    			return id;
    		}
    
    		public int getProduct() {
    			return product;
    		}
    
    		public int getLevel() {
    			return level;
    		}
    
    		public double getXp() {
    			return xp;
    		}
    	}
    
    	private Seed seed;
    
    	private Farming(Seed seed) {
    		this.seed = seed;
    	}
    
    	public static void handleFarm(Player player, Seed seed) {
    		player.getActionManager().setAction(new Farming(seed));
    	}
    
    	public boolean checkAll(Player player) {
    		if (!player.getInventory().hasFreeSlots()) {
    			player.getDialogueManager().startDialogue("SimpleMessage", "Your inventory is full.");
    			return false;
    		}
    		if (player.getSkills().getLevel(Skills.FARMING) < seed.getLevel()) {
    			player.getDialogueManager().startDialogue("SimpleMessage",
    					"You need a farming level of " + seed.getLevel() + " to grow that seed.");
    			return false;
    		}
    		if (!player.getInventory().containsOneItem(seed.getId())) {
    			player.getDialogueManager().startDialogue("SimpleMessage", "You don't have any "
    					+ ItemDefinitions.getItemDefinitions(seed.getId()).getName().toLowerCase() + " to plant.");
    			return false;
    		}
    		return true;
    	}
    
    	@Override
    	public boolean start(Player player) {
    		if (checkAll(player)) {
    			setActionDelay(player, 1);
    			player.setNextAnimation(new Animation(2273));
    			return true;
    		}
    		return false;
    	}
    
    	@Override
    	public boolean process(Player player) {
    		return checkAll(player);
    	}
    
    	@Override
    	public int processWithDelay(Player player) {
    		int amount = 1 + Utils.random(4);
    		player.getInventory().deleteItem(seed.getId(), 1);
    		player.getInventory().addItem(seed.getProduct(), amount);
    		player.getSkills().addXp(Skills.FARMING, seed.getXp());
    		player.addFarmed(1);
    		player.getPackets().sendGameMessage(
    				"You plant the " + ItemDefinitions.getItemDefinitions(seed.getId()).getName().toLowerCase() + ".",
    				true);
    		player.setNextAnimation(new Animation(2273));
    		setActionDelay(player, 3);
    		return 0;
    	}
    
    	@Override
    	public void stop(final Player player) {
    		setActionDelay(player, 3);
    	}
    
    }
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jul 2021
    Posts
    95
    Thanks given
    21
    Thanks received
    19
    Rep Power
    44
    What lol?
    Reply With Quote  
     

  3. Thankful user:



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. Herblore/Farming MY WAY
    By tj007razor in forum Tutorials
    Replies: 41
    Last Post: 06-02-2008, 01:13 AM
  2. Farming V1[USEING GROW]
    By RSSJ in forum Tutorials
    Replies: 7
    Last Post: 10-07-2007, 12:39 AM
  3. Farming
    By Fallen Azn SinZ in forum Tutorials
    Replies: 27
    Last Post: 10-01-2007, 01:03 PM
  4. Farming handled (aznsinz)
    By Kelvin in forum Tutorials
    Replies: 3
    Last Post: 09-27-2007, 01:29 AM
  5. My Small Farming
    By Santa Noobie in forum Tutorials
    Replies: 1
    Last Post: 05-05-2007, 03:38 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
  •