Thread: [PI] Woodcutting Help

Results 1 to 8 of 8
  1. #1 [PI] Woodcutting Help 
    Registered Member Ired's Avatar
    Join Date
    May 2012
    Posts
    160
    Thanks given
    13
    Thanks received
    10
    Rep Power
    12
    Sorry, I'm posting about a 2 year old thread of woodcutting. Just need help with one error I get compiling. Here's what it looks like:



    I just need a better base for WC. I'm using the Blank PI...

    Would I have to edit this method?

    Here's what my Object Class looks like:

    Code:
    package server.model.objects;
    
    import server.Server;
    
    public class Object {
    
    	public int objectId;
    	public int objectX;
    	public int objectY;
    	public int height;
    	public int face;
    	public int type;
    	public int newId;
    	public int tick;
    	public boolean remove;
    
    	public Object(int id, int x, int y, int height, int face, int type,
    			int newId, int ticks, boolean remove) {
    		this.objectId = id;
    		this.objectX = x;
    		this.objectY = y;
    		this.height = height;
    		this.face = face;
    		this.type = type;
    		this.newId = newId;
    		this.tick = ticks;
    		this.remove = remove;
    		Server.objectManager.addObject(this);
    	}
    
    	public int getId() {
    		return this.objectId;
    	}
    
    	public int getX() {
    		return this.objectX;
    	}
    
    	public int getY() {
    		return this.objectY;
    	}
    
    	public int getHeight() {
    		return this.height;
    	}
    
    	public int getFace() {
    		return this.face;
    	}
    
    	public int getType() {
    		return this.type;
    	}
    
    	public int getNewId() {
    		return this.newId;
    	}
    
    	public int getTicks() {
    		return this.tick;
    	}
    
    	public boolean getRemove() {
    		return this.remove;
    	}
    
    }
    Reply With Quote  
     

  2. #2  
    Registered Member
    Karma_K's Avatar
    Join Date
    Nov 2012
    Posts
    4,283
    Thanks given
    152
    Thanks received
    610
    Rep Power
    108
    You need to add another integer to where you declared newObject
    Reply With Quote  
     

  3. #3  
    Registered Member Ired's Avatar
    Join Date
    May 2012
    Posts
    160
    Thanks given
    13
    Thanks received
    10
    Rep Power
    12
    Quote Originally Posted by Karma_K View Post
    You need to add another integer to where you declared newObject
    Am I adding something to the Woodcutting.java or Object.java? Confused.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Karma_K's Avatar
    Join Date
    Nov 2012
    Posts
    4,283
    Thanks given
    152
    Thanks received
    610
    Rep Power
    108
    Quote Originally Posted by Ired View Post
    Am I adding something to the Woodcutting.java or Object.java? Confused.
    Woodcutting.java where you declared new Object..
    Reply With Quote  
     

  5. #5  
    Registered Member Ired's Avatar
    Join Date
    May 2012
    Posts
    160
    Thanks given
    13
    Thanks received
    10
    Rep Power
    12
    Quote Originally Posted by Karma_K View Post
    Woodcutting.java where you declared new Object..
    Code:
    package server.model.players.skills;
    
    import server.model.players.*;
    import server.Config;
    import server.util.Misc;
    import server.event.*;
    import server.model.objects.Object;
    import server.Server;
    
    /**
    * @Author Null++
    */
    
    public class Woodcutting {
    	
    	private Client c;
    	
    	public final int[][] Axe_Settings = {
    		{1351, 1, 1, 879}, //Bronze
    		{1349, 1, 2, 877}, //Iron
    		{1353, 6, 3, 875}, //Steel
    		{1361, 6, 4, 873}, //Black
    		{1355, 21, 5, 871}, //Mithril
    		{1357, 31, 6, 869}, //Addy
    		{1359, 41, 7, 867}, //Rune
    		{6739, 61, 8, 2846}, //Dragon
    		{13661, 41, 8, 10251} //Adze
    	};
    
    	public final int[][] Tree_Settings = {
    		{1276, 1342, 1, 25, 1511, 45, 100}, //Tree
    		{1278, 1342, 1, 25, 1511, 45, 100}, //Tree
    		{1286, 1342, 1, 25, 1511, 45, 100}, //Dead Tree
    		{1281, 1356, 15, 38, 1521, 11, 20}, //Oak
    		{1308, 7399, 30, 68, 1519, 11, 8}, //Willow
    		{5552, 7399, 30, 68, 1519, 11, 8}, //Willow
    		{1307, 1343, 45, 100, 1517, 48, 8}, //Maple
    		{1309, 7402, 60, 175, 1515, 79, 5}, //Yew
    		{1306, 7401, 75, 250, 1513, 150, 3}, //Magic
    		{5551, 7399, 30, 68, 1519, 11, 8}, //Willow
    		{5553, 7399, 30, 68, 1519, 11, 8} //Willow
    	};
    
    	int a = -1;
    
    	public Woodcutting(Client c) {
    		this.c = c;
    	}
    	
    	public void startWoodcutting(final int j, final int x, final int y, final int type) {
    		if (c.isWc)
    			return;
    		if (c.wcing)
    			return;
    		int wcLevel = c.playerLevel[8];
    		a = -1;
    		c.turnPlayerTo(x, y);
    		if (Tree_Settings[j][2] > wcLevel) {
    			c.sendMessage("You need a Woodcutting level of " + Tree_Settings[j][2] + " to cut this tree.");
    			return;
    		}
    		for (int i = 0; i < Axe_Settings.length; i++) {
    			if (c.getItems().playerHasItem(Axe_Settings[i][0]) || c.playerEquipment[c.playerWeapon] == Axe_Settings[i][0]) {
    				if (Axe_Settings[i][1] <= wcLevel) {
    					a = i;
    				}
    			}
    		}
    		if (a == -1) {
    			c.sendMessage("You need an axe to cut this tree.");
    			return;
    		}
    		if (c.getItems().freeSlots() < 1) {
    			c.sendMessage("You do not have enough inventory slots to do that.");
    			return;
    		}
    		c.startAnimation(Axe_Settings[a][3]);
    		c.isWc = true;
    		c.treeX = x;
    		c.treeY = y;
    		c.wcing = true;
    		CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    			@Override
    			public void execute(CycleEventContainer container) {
    				if (!c.isWc) {
    					container.stop();
    					return;
    				}
    				if (c.isWc)
    					c.startAnimation(Axe_Settings[a][3]);
    				if (c.getItems().freeSlots() < 1) {
    					c.sendMessage("You have ran out of inventory slots.");
    					container.stop();
    				}
    				int xp = Tree_Settings[j][3];
    				if (c.getItems().playerHasEquipped(10933)) {
    					xp = (int)(xp * 1.002);
    				}
    				if (c.getItems().playerHasEquipped(10939)) {
    					xp = (int)(xp * 1.008);
    				}
    				if (c.getItems().playerHasEquipped(10940)) {
    					xp = (int)(xp * 1.006);
    				}
    				if (c.getItems().playerHasEquipped(10941)) {
    					xp = (int)(xp * 1.004);
    				}
    				if (c.isWc) {
    					c.getItems().addItem(Tree_Settings[j][4], 1);
    					c.getPA().addSkillXP(xp, 8);
    				}
    				if (c.getItems().freeSlots() < 1) {
    					c.sendMessage("You have ran out of inventory slots.");
    					container.stop();
    				}
    				if (c.isWc)
    					birdNests();
    				if (c.getItems().freeSlots() < 1) {
    					c.sendMessage("You have ran out of inventory slots.");
    					container.stop();
    				}
    				if (Misc.random(100) <= Tree_Settings[j][6]) {
    					cutDownTree(Tree_Settings[j][5], x, y, type, Tree_Settings[j][1], Tree_Settings[j][0]);
    					container.stop();
    				}
    			}
    			@Override
    			public void stop() {
    				c.startAnimation(65535);
    				c.isWc = false;
    				c.treeX = 0;
    				c.treeY = 0;
    				c.wcing = false;
    				return;
    			}
    		}, getTimer(j, a, wcLevel));
    	}
    
    	public int getTimer(int b, int c, int level) {
    		double timer = (int)((Tree_Settings[b][2]  * 2) + 20 + Misc.random(20))-((Axe_Settings[c][2] * (Axe_Settings[c][2] * 0.75)) + level);
    		if (timer < 3.0) {
    			return 3;
    		} else {
    			return (int)timer;
    		}
    	}
    	
    	public void birdNests() {
    		if (Misc.random(100) < 5) {
    			c.getItems().addItem(5070, 1);
    		}
    	}
    	
    	public void cutDownTree(int respawnTime, int x, int y, int type, int i, int j) {
    		new Object(i, x, y, 0, type, 10, j, respawnTime);
    		for (int t = 0; t < Server.playerHandler.players.length; t++) {
    			if (Server.playerHandler.players[t] != null) {
    				if (Server.playerHandler.players[t].treeX == x && Server.playerHandler.players[t].treeY == y) {
    					Server.playerHandler.players[t].isWc = false;
    					Server.playerHandler.players[t].startAnimation(65535);
    					Server.playerHandler.players[t].treeX = 0;
    					Server.playerHandler.players[t].treeY = 0;
    				}
    			}
    		}
    	}
    }
    Highlighted it in Red.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Karma_K's Avatar
    Join Date
    Nov 2012
    Posts
    4,283
    Thanks given
    152
    Thanks received
    610
    Rep Power
    108
    Quote Originally Posted by Ired View Post
    Code:
    package server.model.players.skills;
    
    import server.model.players.*;
    import server.Config;
    import server.util.Misc;
    import server.event.*;
    import server.model.objects.Object;
    import server.Server;
    
    /**
    * @Author Null++
    */
    
    public class Woodcutting {
    	
    	private Client c;
    	
    	public final int[][] Axe_Settings = {
    		{1351, 1, 1, 879}, //Bronze
    		{1349, 1, 2, 877}, //Iron
    		{1353, 6, 3, 875}, //Steel
    		{1361, 6, 4, 873}, //Black
    		{1355, 21, 5, 871}, //Mithril
    		{1357, 31, 6, 869}, //Addy
    		{1359, 41, 7, 867}, //Rune
    		{6739, 61, 8, 2846}, //Dragon
    		{13661, 41, 8, 10251} //Adze
    	};
    
    	public final int[][] Tree_Settings = {
    		{1276, 1342, 1, 25, 1511, 45, 100}, //Tree
    		{1278, 1342, 1, 25, 1511, 45, 100}, //Tree
    		{1286, 1342, 1, 25, 1511, 45, 100}, //Dead Tree
    		{1281, 1356, 15, 38, 1521, 11, 20}, //Oak
    		{1308, 7399, 30, 68, 1519, 11, 8}, //Willow
    		{5552, 7399, 30, 68, 1519, 11, 8}, //Willow
    		{1307, 1343, 45, 100, 1517, 48, 8}, //Maple
    		{1309, 7402, 60, 175, 1515, 79, 5}, //Yew
    		{1306, 7401, 75, 250, 1513, 150, 3}, //Magic
    		{5551, 7399, 30, 68, 1519, 11, 8}, //Willow
    		{5553, 7399, 30, 68, 1519, 11, 8} //Willow
    	};
    
    	int a = -1;
    
    	public Woodcutting(Client c) {
    		this.c = c;
    	}
    	
    	public void startWoodcutting(final int j, final int x, final int y, final int type) {
    		if (c.isWc)
    			return;
    		if (c.wcing)
    			return;
    		int wcLevel = c.playerLevel[8];
    		a = -1;
    		c.turnPlayerTo(x, y);
    		if (Tree_Settings[j][2] > wcLevel) {
    			c.sendMessage("You need a Woodcutting level of " + Tree_Settings[j][2] + " to cut this tree.");
    			return;
    		}
    		for (int i = 0; i < Axe_Settings.length; i++) {
    			if (c.getItems().playerHasItem(Axe_Settings[i][0]) || c.playerEquipment[c.playerWeapon] == Axe_Settings[i][0]) {
    				if (Axe_Settings[i][1] <= wcLevel) {
    					a = i;
    				}
    			}
    		}
    		if (a == -1) {
    			c.sendMessage("You need an axe to cut this tree.");
    			return;
    		}
    		if (c.getItems().freeSlots() < 1) {
    			c.sendMessage("You do not have enough inventory slots to do that.");
    			return;
    		}
    		c.startAnimation(Axe_Settings[a][3]);
    		c.isWc = true;
    		c.treeX = x;
    		c.treeY = y;
    		c.wcing = true;
    		CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    			@Override
    			public void execute(CycleEventContainer container) {
    				if (!c.isWc) {
    					container.stop();
    					return;
    				}
    				if (c.isWc)
    					c.startAnimation(Axe_Settings[a][3]);
    				if (c.getItems().freeSlots() < 1) {
    					c.sendMessage("You have ran out of inventory slots.");
    					container.stop();
    				}
    				int xp = Tree_Settings[j][3];
    				if (c.getItems().playerHasEquipped(10933)) {
    					xp = (int)(xp * 1.002);
    				}
    				if (c.getItems().playerHasEquipped(10939)) {
    					xp = (int)(xp * 1.008);
    				}
    				if (c.getItems().playerHasEquipped(10940)) {
    					xp = (int)(xp * 1.006);
    				}
    				if (c.getItems().playerHasEquipped(10941)) {
    					xp = (int)(xp * 1.004);
    				}
    				if (c.isWc) {
    					c.getItems().addItem(Tree_Settings[j][4], 1);
    					c.getPA().addSkillXP(xp, 8);
    				}
    				if (c.getItems().freeSlots() < 1) {
    					c.sendMessage("You have ran out of inventory slots.");
    					container.stop();
    				}
    				if (c.isWc)
    					birdNests();
    				if (c.getItems().freeSlots() < 1) {
    					c.sendMessage("You have ran out of inventory slots.");
    					container.stop();
    				}
    				if (Misc.random(100) <= Tree_Settings[j][6]) {
    					cutDownTree(Tree_Settings[j][5], x, y, type, Tree_Settings[j][1], Tree_Settings[j][0]);
    					container.stop();
    				}
    			}
    			@Override
    			public void stop() {
    				c.startAnimation(65535);
    				c.isWc = false;
    				c.treeX = 0;
    				c.treeY = 0;
    				c.wcing = false;
    				return;
    			}
    		}, getTimer(j, a, wcLevel));
    	}
    
    	public int getTimer(int b, int c, int level) {
    		double timer = (int)((Tree_Settings[b][2]  * 2) + 20 + Misc.random(20))-((Axe_Settings[c][2] * (Axe_Settings[c][2] * 0.75)) + level);
    		if (timer < 3.0) {
    			return 3;
    		} else {
    			return (int)timer;
    		}
    	}
    	
    	public void birdNests() {
    		if (Misc.random(100) < 5) {
    			c.getItems().addItem(5070, 1);
    		}
    	}
    	
    	public void cutDownTree(int respawnTime, int x, int y, int type, int i, int j) {
    		new Object(i, x, y, 0, type, 10, j, respawnTime);
    		for (int t = 0; t < Server.playerHandler.players.length; t++) {
    			if (Server.playerHandler.players[t] != null) {
    				if (Server.playerHandler.players[t].treeX == x && Server.playerHandler.players[t].treeY == y) {
    					Server.playerHandler.players[t].isWc = false;
    					Server.playerHandler.players[t].startAnimation(65535);
    					Server.playerHandler.players[t].treeX = 0;
    					Server.playerHandler.players[t].treeY = 0;
    				}
    			}
    		}
    	}
    }
    Highlighted it in Red.
    Quote Originally Posted by Karma_K View Post
    You need to add another integer to where you declared new Object
    sorry, but im not gonna spoonfeed you.
    Reply With Quote  
     

  7. #7  
    Registered Member Ired's Avatar
    Join Date
    May 2012
    Posts
    160
    Thanks given
    13
    Thanks received
    10
    Rep Power
    12
    Quote Originally Posted by Karma_K View Post
    sorry, but im not gonna spoonfeed you.
    Lol, I'm not the best at coding. But would I have to add something from this code in Object.java:

    Code:
    public Object(int id, int x, int y, int height, int face, int type,
    			int newId, int ticks, boolean remove) {

    To this code in Woodcutting.java:

    Code:
    new Object(i, x, y, 0, type, 10, j, respawnTime);
    Reply With Quote  
     

  8. #8  
    Registered Member Ired's Avatar
    Join Date
    May 2012
    Posts
    160
    Thanks given
    13
    Thanks received
    10
    Rep Power
    12
    Here's what my firemaking looks like:

    Code:
    								new Object(2732, x, y, 0, 0, 10, 6951, ticks,
    										false);
    The problem I have with my woodcutting is, would I have to declare the respawnTime and not screw things up with the firemaking and that method... Or how would I "adjust" the code for the Woodcutting.
    Reply With Quote  
     


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. Replies: 27
    Last Post: 01-05-2013, 01:11 PM
  2. [PI] Woodcutting help
    By mc wobbla in forum Help
    Replies: 2
    Last Post: 12-06-2012, 02:47 AM
  3. [PI] Woodcutting help
    By mc wobbla in forum Help
    Replies: 0
    Last Post: 12-06-2012, 01:34 AM
  4. PI woodcutting help
    By corndogs in forum Help
    Replies: 1
    Last Post: 07-01-2012, 01:24 AM
  5. [PI] Woodcutting & Mining Help...
    By Famouz in forum Help
    Replies: 17
    Last Post: 05-30-2012, 09:27 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
  •