Thread: Delta Woodcutting [317/377]

Results 1 to 10 of 10
  1. #1 Delta Woodcutting [317/377] 
    Registered Member
    Iwin's Avatar
    Join Date
    Mar 2008
    Age
    30
    Posts
    677
    Thanks given
    12
    Thanks received
    56
    Rep Power
    245
    Since I quit coding RSPS over a year ago, I believe it's my job to help the community by releasing some of my codes.

    Today I'm releasing my Woodcutting.


    I'm not going to spoon feed anyone.

    If you know what to do with the code, good for you. If not, I'm sorry.

    I'm not 100% sure this is the most efficient way of doing woodcutting, but in Delta, you can't really go wrong.

    There will be things you will need to change out with your own code, such as "p.resetSkills(0);".
    I use it to end all actions. It's kinda a cheap way of doing it, but it worked for my needs.

    In reality, it works.. but it's not really the best way.

    Code:
    	public void resetSkills(int on) {
    		if (on > 0
    				&& (!Cooking && !Fishing && !Mining && !Woodcutting
    						&& !Smithing && !GoAnvil && !Smelting && !WalkToFurnace
    						&& !SmeltX && !CraftingLeather && !Fletching
    						&& !CraftingGems && !Herblore))
    			return;
    		// if on is 1 then make sure a skill in true
    		// if on is 0 then reset all no matter what
    		resetSkills = true;
    	}
    Then goes to 100ms loop and
    Code:
    if(c.resetSkills){
    /* Woodcutting */
    c.Woodcutting = false;
    c.TreeID = -1;
    c.TreeX = -1;
    c.TreeY = -1;
    c.TreeType = -1;
    
    c.resetAnimation();
    c.resetSkills = false;
    }
    Spoiler for How It Works:

    How this works:
    - Click tree
    - Set tree data(treeID, x, y)
    - Sets axe data(checks axe level, if wielded or in inventory)
    - Checks to see if near tree
    - Check for axe
    - Checks if Woodcutting level is high enough
    - Check for best axe(if one's not wielded)
    - Checks to see if coords are a stump(prevents cheaters)
    - Checks Inventory Space
    - Starts Woodcutting loop

    How tree's work:
    - TreeID, X, Y, *health*, total logs

    if tree not added, add tree:
    Code:
    		if (!isTree(c.TreeX, c.TreeY)) {
    			Trees tree = new Trees(c.TreeID, c.TreeX, c.TreeY);
    			tree.setTreeHits(tree,
    					10 + Misc.random((int) (treeData(c, "hits") - 10)));
    			tree.setTreeLogs(tree, Misc.random2((int) treeData(c, "logamt")));
    			Server.trees.add(tree);
    		}
    Each axe has it's own "strength" and each tick (600ms), does a 0-strength *damage* to the tree's *health*.
    When the health < 0, the player who did the last damage, gets the log.
    When logs left < 1, turn into stump
    Then stump timer starts.
    CBF to continue process.


    Spoiler for Features:

    • All Trees
    • All Axes
    • All Animations
    • Proper Respawn Rates
    • Proper Stump ID's
    • No Known Memory Leaks
    • Picks best axe
    • Cannot Cut Down 'Invisible' Tree's
    • Uses ArrayList instead of a multidimensional array

    There's really not much to say about this, it works like it's supposed to.


    Spoiler for Pictures:






    Spoiler for Code:

    Spoiler for Woodcutting.java (skill):

    Code:
    package com.iwinscape.player.skill;
    
    import com.iwinscape.global.Server;
    import com.iwinscape.global.thread.PlayerHandler;
    import com.iwinscape.object.Stumps;
    import com.iwinscape.object.Trees;
    import com.iwinscape.player.Client;
    import com.iwinscape.player.Misc;
    
    public class Woodcutting {
    
    	public static int[][] axes = {
    	/* ID, animi,str,lvlreq */
    	{ 1351, 879, 1, 1 },// Bronze
    			{ 1349, 877, 2, 1 },// Iron
    			{ 1353, 875, 3, 6 },// Steel
    			{ 1361, 873, 3, 6 },// Black
    			{ 1355, 871, 4, 21 },// Mithril
    			{ 1357, 869, 5, 31 },// Adamant
    			{ 1359, 867, 8, 41 },// Rune
    			{ 6739, 2846, 10, 61 },// Dragon
    			{ 12652, 2846, 10, 61 },// Inferno adze
    	};
    
    	public static double[][] trees = {
    	/* level req, exp, logID, respawn, hits before log, logs, stumpID */
    	{ 1, 25, 1511, 60, 20, 1, 1344 }, // normal
    			{ 1, 25, 1511, 60, 20, 1, 1347 }, // dead
    			{ 1, 25, 1511, 60, 20, 1, 4821 }, // jungle
    			{ 1, 25, 2862, 60, 20, 1, 3371 }, // achey
    			{ 15, 37.5, 1521, 100, 30, 25, 1356 }, // oak
    			{ 30, 67.5, 1519, 120, 40, 30, 7399 }, // willow
    			{ 35, 85, 6333, 60, 50, 30, 9037 }, // teak
    			{ 36, 0, 771, 10, 20, 1, 771 }, // dramen tree
    			{ 45, 100, 1517, 120, 80, 55, 7400 }, // maple
    			{ 45, 82, 1511, 120, 80, 10, 4061 }, // hollow
    			{ 50, 125, 6332, 180, 100, 25, 9035 }, // mahogany
    			{ 60, 175, 1515, 180, 150, 75, 7402 }, // yew
    			{ 75, 250, 1513, 380, 300, 80, 7401 }, // magic
    	};
    
    	private static int arrayAxeID(Client c, int data) {
    		return axes[data][0];
    	}
    
    	private static int arrayAxeAnimi(Client c, int data) {
    		return axes[data][1];
    	}
    
    	private static int arrayAxeStr(Client c, int data) {
    		return axes[data][2];
    	}
    
    	private static int arrayAxeReq(Client c, int data) {
    		return axes[data][3];
    	}
    
    	private static int currentAxeStr(Client c) {
    		return c.AxeHits;
    	}
    
    	private static int currentAxeID(Client c) {
    		return c.axeID;
    	}
    
    	private static int currentAxeAnimi(Client c) {
    		return c.AxeAnimi;
    	}
    
    	private static void setAxeID(Client c, int id) {
    		c.axeID = id;
    	}
    
    	private static void setAxeAnimi(Client c, int id) {
    		c.AxeAnimi = id;
    	}
    
    	private static void setAxeStr(Client c, int id) {
    		c.AxeHits = id;
    	}
    
    	private static void setAxeData(Client c, int data) {
    		setAxeID(c, arrayAxeID(c, data));
    		setAxeAnimi(c, arrayAxeAnimi(c, data));
    		setAxeStr(c, arrayAxeStr(c, data));
    	}
    
    	private static int getWeapon(Client c) {
    		return c.playerEquipment[c.playerWeapon];
    	}
    
    	private static int getWoodcuttingLevel(Client c) {
    		return c.playerLevel[c.playerWoodcutting];
    	}
    
    	private static boolean axeEquipped(Client c) {
    		if (getWeapon(c) < 1) {
    			return false;
    		}
    		for (int i = 0; i < axes.length; i++) {
    			if (getWeapon(c) == arrayAxeID(c, i)
    					&& getWoodcuttingLevel(c) >= arrayAxeReq(c, i)) {
    				setAxeData(c, i);
    				return true;
    			}
    		}
    		return false;
    	}
    
    	private static boolean axeInInventory(Client c) {
    		/* if usable axe in inventory */
    		for (int i = 0; i < axes.length; i++) {
    			if (c.playerHasItem(arrayAxeID(c, i))
    					&& getWoodcuttingLevel(c) >= arrayAxeReq(c, i)) {
    				return true;
    			}
    		}
    		return false;
    	}
    
    	private static void getAxeData(Client c) {
    		if (!axeEquipped(c)) {
    			if (axeInInventory(c)) {
    				for (int i = 0; i < axes.length; i++) {
    					if (c.playerHasItem(arrayAxeID(c, i))) {
    						if (getWoodcuttingLevel(c) >= arrayAxeReq(c, i)) {
    							if (arrayAxeStr(c, i) > currentAxeStr(c)) {
    								setAxeData(c, i);
    							}
    						}
    					}
    				}
    			}
    		}
    
    	}
    
    	private static double treeData(Client c, String type) {
    		switch (type) {
    		case "level":
    			return trees[c.TreeType][0];
    		case "exp":
    			return trees[c.TreeType][1];
    		case "log":
    			return trees[c.TreeType][2];
    		case "respawn":
    			return trees[c.TreeType][3];
    		case "hits":
    			return trees[c.TreeType][4];
    		case "logamt":
    			return trees[c.TreeType][5];
    		case "stump":
    			return trees[c.TreeType][6];
    		default:
    			return -1;
    		}
    	}
    
    	public static int treeType(Client c, int objectID) {
    		switch (objectID) {
    		case 1276:// Tree
    		case 1277:
    		case 1278:
    		case 1279:
    		case 1280:
    		case 1315:// Evergreen
    		case 1316:
    		case 1318:
    		case 1319:
    		case 1330:// Tree
    		case 1331:
    		case 1332:
    		case 2409:
    		case 3033:
    		case 3034:
    		case 3035:
    		case 3036:
    		case 3879:
    		case 3881:
    		case 3882:
    		case 3883:
    		case 10041:
    		case 14308:
    		case 14309:
    			return 0;// Normal
    
    		case 1282:
    		case 1283:
    		case 1284:
    		case 1285:
    		case 1286:
    		case 1289:
    		case 1290:
    		case 1291:
    		case 1365:
    		case 1383:
    		case 1384:
    		case 5902:
    		case 5903:
    		case 5904:
    			return 1;// Dead
    
    			// return 2;// Jungle
    
    		case 2023:
    			return 3;// Achey
    
    		case 1281:
    		case 3037:
    		case 8467:
    			return 4;// Oak
    
    		case 1308:
    		case 5551:
    		case 5552:
    		case 5553:
    		case 8488:
    			return 5;// willow
    
    		case 9036:
    			return 6;// teak
    
    		case 1292:
    			return 7;// Dramen
    
    		case 1307:
    		case 4674:
    		case 8444:
    			return 8;// maple
    
    		case 2289:
    		case 4060:
    			return 9;// hollow
    
    		case 9034:
    			return 10;// mahogany
    
    		case 1309:
    		case 8513:
    			return 11;// yew
    
    		case 1306:
    		case 8409:
    			return 12;// magic
    
    		default:
    			return -1;
    		}
    	}
    
    	public static void WC(Client c) {
    		getAxeData(c);
    		c.TreeType = treeType(c, c.TreeID);
    
    		if (treeType(c, c.TreeID) < 0) {
    			c.sM("Error with tree ID: " + c.TreeID);
    			c.resetSkills(0);
    			return;
    		}
    
    		if (currentAxeID(c) < 0 || currentAxeAnimi(c) < 0) {
    			c.sM("You need an axe to cut down trees!");
    			c.resetSkills(0);
    			return;
    		}
    		if (getWoodcuttingLevel(c) < treeData(c, "level")) {
    			c.sM("Your woodcutting level isn't high enough to chop these trees.");
    			c.resetSkills(0);
    			return;
    		}
    		if (Stumps.isStump(c.TreeX, c.TreeY)) {
    			c.resetSkills(0);
    			return;
    		}
    		SetTree(c);
    
    	}
    
    	private static boolean isTree(int X, int Y) {
    		for (Trees i : Server.trees) {
    			if (i.getTreeX(i) == X && i.getTreeY(i) == Y) {
    				i.setRemovalCounter(i, 480);
    				return true;
    			}
    		}
    		return false;
    	}
    
    	private static void SetTree(Client c) {
    		if (c.freeSlots() < 1) {
    			c.sM("Not enough space in your inventory.");
    			c.resetSkills(0);
    			return;
    		}
    
    		c.startAnimation(currentAxeAnimi(c));
    
    		if (!isTree(c.TreeX, c.TreeY)) {
    			Trees tree = new Trees(c.TreeID, c.TreeX, c.TreeY);
    			tree.setTreeHits(tree,
    					10 + Misc.random((int) (treeData(c, "hits") - 10)));
    			tree.setTreeLogs(tree, Misc.random2((int) treeData(c, "logamt")));
    			Server.trees.add(tree);
    		}
    
    		for (int i = 0; i < Server.trees.size(); i++) {
    			Trees tree = Server.trees.get(i);
    			if (tree.getTreeID(tree) == c.TreeID) {
    				if (tree.getTreeX(tree) == c.TreeX
    						&& tree.getTreeY(tree) == c.TreeY) {
    					tree.setTreeHits(
    							tree,
    							tree.getTreeHits(tree)
    									- Misc.random2(currentAxeStr(c)));
    
    					if (tree.getTreeHits(tree) < 1) {
    						tree.removeLog(tree);
    						getLogs(c);
    
    
    						if (tree.getTreeLogsLeft(tree) < 1) {
    							Server.stumps.add(new Stumps((int) treeData(c,
    									"stump"), tree.getTreeX(tree), tree
    									.getTreeY(tree), (int) treeData(c,
    									"respawn"), tree.getTreeID(tree)));
    
    							for (int i1 = 0; i1 < PlayerHandler.maxPlayers; i1++) {
    								if (PlayerHandler.players[i1] != null) {
    									Client p = (Client) PlayerHandler.players[i1];
    									if (p.playerName != null) {
    										if (c.TreeID == p.TreeID
    												&& c.TreeX == p.TreeX
    												&& c.TreeY == p.TreeY) {
    											p.sM("The tree has fallen.");
    											p.resetSkills(0);
    										}
    									}
    								}
    							}
    						}
    						tree.checkLogs(tree);
    						tree.setTreeHits(tree, 10 + Misc
    								.random((int) (treeData(c, "hits") - 10)));
    						return;
    					}
    				}
    			}
    		}
    	}
    
    	private static void getLogs(Client c) {
    		/* GUI */
    		c.addItem((int) treeData(c, "log"), 1);
    		if (!c.Woodcutting)
    			return;
    		c.addSkillXP(treeData(c, "exp"), c.playerWoodcutting);
    		c.sM("You get some logs.");
    		setAxeAnimi(c, -1);
    		setAxeID(c, -1);
    		setAxeStr(c, -1);
    	}
    }


    Spoiler for Woodcutting.java (thread):

    Code:
    package com.iwinscape.global.thread;
    
    import com.iwinscape.global.Server;
    import com.iwinscape.object.Stumps;
    import com.iwinscape.object.Trees;
    import com.iwinscape.player.Client;
    import com.iwinscape.player.Player;
    
    public class Woodcutting extends Thread {
    	/* Cycle info */
    	int cycleTime = 600;
    	long lastTicks = System.currentTimeMillis();
    
    	/* Woodcutting stuff */
    
    	/* 0 = treeID, 1 = treeX, 2 = treeY, 3 = logs left, 4 = hits before log */
    
    	public void run() {
    		while (true) {
    
    			long timeSpent = System.currentTimeMillis() - lastTicks;
    
    			if (timeSpent >= cycleTime) {
    				timeSpent = cycleTime;
    			}
    
    			try {
    				Thread.sleep(cycleTime - timeSpent);
    			} catch (Exception e) {
    
    			}
    
    			lastTicks = System.currentTimeMillis();
    
    			/* respawns trees */
    			Stumps.respawnCount();
    
    			/* removes inactive tree's after 5min */
    
    			for (int i = 0; i < Server.trees.size(); i++) {
    				Trees tree = Server.trees.get(i);
    				tree.setRemovalCounter(tree, tree.getTreeCounter(tree) - 1);
    				if (tree.getTreeCounter(tree) < 0) {
    					tree.removeTree(tree);
    				}
    			}
    
    			for (Player p : PlayerHandler.players) {
    				if ((p == null) || !p.isActive)
    					continue;
    
    				Client c = (Client) p;
    
    				if ((c != null) && !c.disconnected && p.isActive) {
    					if (PlayerHandler.getPlayerID(c.playerName) == c.playerId) {
    						if (c.Woodcutting) {
    							if (c.oldx == c.posX
    									&& c.oldy == c.posY
    									&& c.GoodDistance(c.skillX, c.skillY,
    											c.posX, c.posY, 3)) {
    								/* cut tree here */
    								com.iwinscape.player.skill.Woodcutting.WC(c);
    							}
    							c.oldx = c.posX;
    							c.oldy = c.posY;
    						}
    					}
    				}
    			}
    		}
    	}
    
    }


    Spoiler for Array Lists:

    Code:
    import java.util.ArrayList;
    
    	public static ArrayList<com.iwinscape.object.Trees> trees = new ArrayList<com.iwinscape.object.Trees>();
    	
    	public static ArrayList<com.iwinscape.object.Stumps> stumps = new ArrayList<com.iwinscape.object.Stumps>();


    Spoiler for Stumps.java:

    Code:
    package com.iwinscape.object;
    
    import com.iwinscape.global.Server;
    import com.iwinscape.player.Client;
    import com.iwinscape.player.Misc;
    
    public class Stumps {
    
    	int stumpID;
    	int stumpX;
    	int stumpY;
    	int stumpDirection;
    	public int countTillRemoval;
    	int treeID;
    
    	public Stumps(int stumpID, int stumpX, int stumpY, int respawn, int treeID) {
    		this.stumpID = stumpID;
    		this.stumpX = stumpX;
    		this.stumpY = stumpY;
    		this.stumpDirection = Misc.random(3);
    		this.countTillRemoval = respawn;
    		this.treeID = treeID;
    		Client.makeGlobalObject(stumpX, stumpY, stumpID, this.stumpDirection,
    				10);
    	}
    
    	public static boolean isStump(int stumpX, int stumpY) {
    		for (Stumps i : Server.stumps) {
    			if (i.stumpX == stumpX && i.stumpY == stumpY) {
    				return true;
    			}
    		}
    		return false;
    	}
    
    	public static void respawnCount() {
    		for (int i = 0; i < Server.stumps.size(); i++) {
    			Stumps stump = Server.stumps.get(i);
    			if (stump.countTillRemoval-- < 1) {
    				Client.makeGlobalObject(stump.stumpX, stump.stumpY,
    						stump.treeID, 0, 10);
    				Server.stumps.remove(stump);
    			}
    		}
    	}
    }


    Spoiler for Trees.java:

    Code:
    package com.iwinscape.object;
    
    import com.iwinscape.global.Server;
    
    public class Trees {
    	private int treeID;
    	private int treeX;
    	private int treeY;
    	private int logsLeft;
    	private int hitsBeforeLog;
    	private int countTillRemoval;
    
    	public Trees(int treeID, int treeX, int treeY) {
    		this.treeID = treeID;
    		this.treeX = treeX;
    		this.treeY = treeY;
    		this.countTillRemoval = 480; // 5 minutes
    	}
    
    	public int getTreeID(Trees tree) {
    		return treeID;
    	}
    
    	public int getTreeX(Trees tree) {
    		return treeX;
    	}
    
    	public int getTreeY(Trees tree) {
    		return treeY;
    	}
    
    	public int getTreeLogsLeft(Trees tree) {
    		return logsLeft;
    	}
    
    	public int getTreeHits(Trees tree) {
    		return hitsBeforeLog;
    	}
    
    	public int getTreeCounter(Trees tree) {
    		return countTillRemoval;
    	}
    
    	public void setTreeHits(Trees tree, int value) {
    		hitsBeforeLog = value;
    	}
    
    	public void setTreeLogs(Trees tree, int value) {
    		logsLeft = value;
    	}
    
    	public void setRemovalCounter(Trees tree, int value) {
    		countTillRemoval = value;
    	}
    
    	public void removeLog(Trees tree) {
    		logsLeft--;
    	}
    
    	public void removeTree(Trees tree) {
    		Server.trees.remove(tree);
    	}
    
    	public void checkLogs(Trees tree) {
    		if (tree.logsLeft < 1) {
    			Server.trees.remove(tree);
    		}
    	}
    
    }


    Spoiler for Object Click:

    Code:
    		if (com.iwinscape.player.skill.Woodcutting.treeType(c, objectID) > -1) {
    			c.TreeID = objectID;
    			c.TreeX = objectX;
    			c.TreeY = objectY;
    			c.skillX = objectX;
    			c.skillY = objectY;
    			c.Woodcutting = true;
    			return;
    		}


    Spoiler for Threads:

    Code:
    			Woodcutting wc = new Woodcutting();
    			wc.setName("Woodcutting");
    			wc.start();




    Spoiler for Notes:

    You will need to import classes


    I'm pretty sure that's all I have to say.

    I'll try and answer any questions.
    [SPOIL]
    [/SPOIL]
    Reply With Quote  
     

  2. #2  
    Registered Member Kota Ko's Avatar
    Join Date
    Aug 2009
    Age
    26
    Posts
    1,040
    Thanks given
    39
    Thanks received
    61
    Rep Power
    39
    Looks good, but no one uses delta as much... or at all lol
    Reply With Quote  
     

  3. #3  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    Yikes. That's not so good. Just because you're using a bad base, doesn't mean you should write bad code. Thanks anyway I guess.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Iwin's Avatar
    Join Date
    Mar 2008
    Age
    30
    Posts
    677
    Thanks given
    12
    Thanks received
    56
    Rep Power
    245
    Quote Originally Posted by Zivik View Post
    Yikes. That's not so good. Just because you're using a bad base, doesn't mean you should write bad code. Thanks anyway I guess.
    What makes this bad code? do point out the specific parts.

    And if you're talking about the timer/thread/loop whatever the hell you wanna call it. I already said it's not the best. The rest of the code is good.

    Quote Originally Posted by Dakota Chest View Post
    Looks good, but no one uses delta as much... or at all lol
    My first goal was to change the way people look at Delta, and to see what I personally can do.

    I believe I did quiet a good job, but I kinda lost interest in RSPS recently and do not plan on going back.

    And putting in a little effort, this woodcutting could be added to any server. It's just the effort that will turn people away.
    [SPOIL]
    [/SPOIL]
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Jun 2012
    Posts
    101
    Thanks given
    0
    Thanks received
    31
    Rep Power
    26
    very messy, and why would you use a separate thread just to handle the woodcutting process?
    Reply With Quote  
     

  6. #6  
    Registered Member
    Iwin's Avatar
    Join Date
    Mar 2008
    Age
    30
    Posts
    677
    Thanks given
    12
    Thanks received
    56
    Rep Power
    245
    Quote Originally Posted by Mpeg View Post
    very messy, and why would you use a separate thread just to handle the woodcutting process?
    How's it "messy", and any normal computer that's halfway decent can handle 100k+ threads before maxing out.
    not saying that 100k threads is normal, but adding separate threads for specific tasks reduces lag on players.

    And like I've said. The timer/thread isn't good. It was there to get the job done.
    [SPOIL]
    [/SPOIL]
    Reply With Quote  
     

  7. #7  
    Banned

    Join Date
    May 2011
    Posts
    1,773
    Thanks given
    854
    Thanks received
    853
    Rep Power
    0
    Well atleast its somewhat object oriented and better than PI default woodcutting i suppose whatsup with this tho lol;

    Code:
    this.stumpDirection = Misc.random(3);
    If its just a random value why store it in every stump object
    Reply With Quote  
     

  8. #8  
    Registered Member
    Iwin's Avatar
    Join Date
    Mar 2008
    Age
    30
    Posts
    677
    Thanks given
    12
    Thanks received
    56
    Rep Power
    245
    Quote Originally Posted by Poesy700 View Post
    Well atleast its somewhat object oriented and better than PI default woodcutting i suppose whatsup with this tho lol;

    Code:
    this.stumpDirection = Misc.random(3);
    If its just a random value why store it in every stump object
    It's to orient the direction of each stump. I know it seems stupid, but I didn't want all the stumps to be set at a default direction. lol

    Edit: I guess I could have done that when it spawned the object. But I didn't think of it atm. If someone wants to change it, they can feel free too lol
    [SPOIL]
    [/SPOIL]
    Reply With Quote  
     

  9. #9  
    Banned

    Join Date
    May 2011
    Posts
    1,773
    Thanks given
    854
    Thanks received
    853
    Rep Power
    0
    Quote Originally Posted by Iwin View Post
    It's to orient the direction of each stump. I know it seems stupid, but I didn't want all the stumps to be set at a default direction. lol
    I know what it is for but you shouldnt store the stump direction in the Stump object.

    You could just do misc.random in the object spawning method itself since its the same method your always calling.
    Reply With Quote  
     

  10. #10  
    Registered Member

    Join Date
    Nov 2014
    Posts
    253
    Thanks given
    39
    Thanks received
    146
    Rep Power
    248
    Quote Originally Posted by Iwin View Post
    What makes this bad code? do point out the specific parts.

    And if you're talking about the timer/thread/loop whatever the hell you wanna call it. I already said it's not the best. The rest of the code is good.



    My first goal was to change the way people look at Delta, and to see what I personally can do.

    I believe I did quiet a good job, but I kinda lost interest in RSPS recently and do not plan on going back.

    And putting in a little effort, this woodcutting could be added to any server. It's just the effort that will turn people away.
    Okay, ignoring the structural poority let us just talk about some dumb flaws:

    You're passing things into methods that are never used, i.e.
    Code:
     					if (tree.getTreeHits(tree) < 1) {
    						tree.removeLog(tree);
    						getLogs(c);
    Why the hell do you need to pass in tree?

    or another example

    Code:
    	private static int arrayAxeID(Client c, int data) {
    		return axes[data][0];
    	}
    You have an ArrayList of trees inside Server? why would you put it there?

    Code:
    public class Tree { 
    
    private static List<Tree> listOfTrees = new ArrayList<>();
    
    public Tree(...) {
    ...
    listOfTrees.add(this);
    }
    
    public void destroy() { 
    ...
    listOfTrees.remove(this);
    }
    
    }
    instead of doing all that ridiculousness.

    Conventions are just terrible really I'm not a book so I'm not going to go over all of them

    God those arrays are disgusting and hard to maintain, use an enum or even a map

    and so much more
    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: 5
    Last Post: 11-20-2014, 03:53 AM
  2. 317/377/ANY Small Framework
    By Frosty Teh Snowman in forum Downloads
    Replies: 7
    Last Post: 09-28-2013, 08:45 PM
  3. Replies: 13
    Last Post: 08-29-2008, 05:47 PM
  4. My 317/377 client
    By x d00m x in forum RS2 Client
    Replies: 18
    Last Post: 07-24-2008, 07:19 PM
  5. Anyone got these 317 - 377 models
    By Clienthax in forum RS2 Client
    Replies: 8
    Last Post: 04-30-2008, 04:56 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
  •