Thread: Woodcutting Issue

Results 1 to 4 of 4
  1. #1 Woodcutting Issue 
    Banned
    Join Date
    Apr 2014
    Posts
    869
    Thanks given
    515
    Thanks received
    202
    Rep Power
    0
    Mod+ close pls
     

  2. #2  
    Extreme Donator


    Join Date
    Nov 2011
    Posts
    311
    Thanks given
    15
    Thanks received
    94
    Rep Power
    361
    Can you post your woodcutting class and the lines of code that says "You need a hatchet to cut this tree".
     

  3. #3  
    Banned
    Join Date
    Apr 2014
    Posts
    869
    Thanks given
    515
    Thanks received
    202
    Rep Power
    0
    Quote Originally Posted by Guthans View Post
    Can you post your woodcutting class and the lines of code that says "You need a hatchet to cut this tree".

    Code:
    package server.model.players.skills;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import server.model.players.Client;
    import server.cycle.*;
    import server.util.Misc;
    import server.model.players.Experience;
    import server.Config;
    import server.world.ObjectHandler;
    import server.model.objects.Objects;
    
    public class Woodcutting {
    
    	private Client c;
    
    	public Woodcutting(Client c) {
    		this.c = c;
    	}
    
    	public static enum Hatchet {
    		BRONZE(1351, 1, 879),
    		IRON(1349, 1, 877),
    		STEEL(1353, 6, 875),
    		BLACK(1361, 6, 873),
    		MITHRIL(1355, 21, 871),
    		ADAMANT(1357, 31, 869),
    		RUNE(1359, 41, 867),
    		DRAGON(6739, 61, 2846);
    
    		private int id, req, anim;
    
    		private Hatchet(int id, int level, int animation) {
    			this.id = id;
    			this.req = level;
    			this.anim = animation;
    		}
    
    		public static Map<Integer, Hatchet> hatchets = new HashMap<Integer, Hatchet>();
    
    
    		public static Hatchet forId(int id) {
    			return hatchets.get(id);
    		}
    
    		static {
    			for(Hatchet hatchet : Hatchet.values()) {
    				hatchets.put(hatchet.getId(), hatchet);
    			}
    		}
    
    		public int getId() {
    			return id;
    		}
    
    		public int getRequiredLevel() {
    			return req;
    		}
    
    		public int getAnim() {
    			return anim;
    		}
    	}
    
    	private enum Trees {
    		NORMAL(1, 25, 1511, new int[] { 1276, 1277, 1278, 1279, 1280, 1282,
    				1283, 1284, 1285, 1286, 1289, 1290, 1291, 1315, 1316, 1318,
    				1319, 1330, 1331, 1332, 1365, 1383, 1384, 3033, 3034, 3035,
    				3036, 3881, 3882, 3883, 5902, 5903, 5904 }, 2, 10, false),
    				ACHEY(1, 25, 2862, new int[] { 2023 }, 1, 10, false),
    				OAK(15, 38, 1521, new int[] { 1281, 3037 }, 3, 15, true),
    				WILLOW(30, 68, 1519, new int[] { 1308, 5551, 5552, 5553 }, 4, 15, true),
    				TEAK(35, 85, 6333, new int[] { 9036 }, 4, 20, true),
    				DRAMEN(36, 36, 771, new int[] { 1292 }, 2, 20, true),
    				MAPLE(45, 100, 1517, new int[] { 1307, 4677 }, 5, 25, true),
    				MAHOGANY(50, 158, 6332, new int[] { 9034 }, 6, 30, true),
    				YEW(60, 175, 1515, new int[] { 1309 }, 7, 40, true),
    				MAGIC(75, 200, 1513, new int[] { 1306 }, 8, 50, true);
    
    		private int[] objects;
    		private int req, xp, log, ticks, time;
    		private boolean multi;
    
    		private Trees(int req, int xp, int log, int[] obj, int ticks, int time, boolean multi) {
    			this.req = req;
    			this.xp = xp;
    			this.log = log;
    			this.objects = obj;
    			this.ticks = ticks;
    			this.multi = multi;
    			this.time = time;
    		}
    		
    		public boolean isMulti() {
    			return multi;
    		}
    		
    		public int getTicks() {
    			return ticks;
    		}
    
    		public int getReward() {
    			return log;
    		}
    
    		public int getXp() {
    			return xp;
    		}
    
    		public int getReq() {
    			return req;
    		}
    
    		public int getTime() {
    			return time;
    		}
    
    		private static final Map<Integer, Trees> tree = new HashMap<Integer, Trees>();
    
    		public static Trees forId(int id) {
    			return tree.get(id);
    		}
    
    		static {
    			for (Trees t : Trees.values()) {
    				for (int obj : t.objects) {
    					tree.put(obj, t);
    				}
    			}
    		}
    	}
    
    	private int hasHatchet() {
    		for (Hatchet h : Hatchet.values()) {
    			if (c.playerEquipment[c.playerWeapon] == h.getId()) {
    				return h.getId();
    			} else if (c.getItems().playerHasItem(h.getId())) {
    				return h.getId();
    			}
    		}
    		return -1;
    	}
    
    	public void cutWood(final int objId) {
    		final Hatchet h = Hatchet.forId(hasHatchet());
    		if (h == null || c.playerLevel[c.playerWoodcutting] < h.getRequiredLevel()) {
    			c.sendMessage("You don't have a hatchet which you can use.");
    			return;
    		}
    		final Trees t = Trees.forId(objId);
    		if (t == null || ObjectHandler.objectExists(c.objectX, c.objectY, c.heightLevel) != null && objId != 1306)
    			return;
    		if (c.playerLevel[c.playerWoodcutting] < t.getReq()) {
    			c.sendMessage("You don't have a high enough woodcutting level to cut this tree.");
    			return;
    		}
    		c.sendMessage("You swing your hatchet at the tree.");
    		if (c.isWoodcutting)
    			return;
    		c.isWoodcutting = true;
    		c.turnPlayerTo(c.objectX, c.objectY);
    		final int objectX = c.objectX;
    		final int objectY = c.objectY;
    		final int distanceObject = c.objectDistance;
    		c.startAnimation(h.getAnim());
    		c.stopPlayerSkill = false;
    		CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    			int reqCycle = (int)(t.getTicks() + Misc.random(3)) / 2;
    			int cycle = 0;
    			@SuppressWarnings("static-access")
    			public void execute(CycleEventContainer container) {
    				if (c.stopPlayerSkill || !c.isWoodcutting)
    					container.stop();
    				else if (!Misc.goodDistance(objectX, objectY, c.absX, c.absY, distanceObject + 1))
    					container.stop();
    				else if (ObjectHandler.objectExists(objectX, objectY, c.heightLevel) != null && objId != 1306)
    					container.stop();
    				else {
    					if (cycle != reqCycle) {
    						cycle++;
    						c.startAnimation(h.getAnim());
    					} else {
    						if (!c.getItems().addItem(t.getReward(), 1)) {
    							container.stop();
    							return;
    						}
    						Experience.addExperience(c, t.getXp()*Config.WOODCUTTING_EXPERIENCE, c.playerWoodcutting);
    						c.getPA().refreshSkill(c.playerWoodcutting);
    						c.sendMessage("You manage to cut some "+c.getItems().getItemName(t.getReward()).toLowerCase()+".");
    						cycle = 0;
    						reqCycle = (int)(t.getTicks() + Misc.random(3)) / 2;
    						if (addStump(t.getTime()) || !t.isMulti()) {
    							Objects object = new Objects(1341, objectX+1, objectY+1, c.heightLevel, 0, 10, (int)(t.getTime()/0.60));
    							object.setReplacement(objId);
    							ObjectHandler.placeSpecialObject(object, true);
    							Objects object2 = new Objects(-1, objectX, objectY, c.heightLevel, 0, 10, (int)(t.getTime()/0.60));
    							ObjectHandler.placeSpecialObject(object2, true);
    							container.stop();
    						}
    					}
    				}
    			}
    			public void stop() {
    				c.stopPlayerSkill = false;
    				c.isWoodcutting = false;
    				c.startAnimation(65535);				
    			}
    		}, 2);
    	}
    
    	private boolean addStump(int ticks) {
    		return (Misc.random(ticks) < 5);
    	}
    }
     

  4. #4  
    Banned
    Join Date
    Apr 2014
    Posts
    869
    Thanks given
    515
    Thanks received
    202
    Rep Power
    0
    Fixed, close !
     


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. WoodCutting Issue rep+++ thank
    By Tringan in forum Help
    Replies: 9
    Last Post: 08-31-2011, 07:17 PM
  2. ---- Realistic Mining + Woodcutting ----
    By MrWlcked in forum Tutorials
    Replies: 153
    Last Post: 06-08-2008, 04:02 AM
  3. [TuT]90% Full rs-realistic woodcutting
    By Wolf in forum Tutorials
    Replies: 11
    Last Post: 08-21-2007, 08:25 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •