private static void harvestFruit(Player p, Patch patch) { if (p.getTemporaryAttribute("unmovable") != null) { return; } p.setLastAnimation(new Animation(2282)); p.setTemporaryAttribute("unmovable", true); patch.setWeeding(true); Event harvestFruitEvent = new Event(1700); harvestFruitEvent.setAction(() => { if (patch.getStatus() == patch.chopStatus() || p.isDisconnected() || p.isDestroyed() || p.isDead() || p.getTemporaryAttribute("teleporting") != null) { harvestFruitEvent.stop(); return; } p.setLastAnimation(new Animation(2282)); string s = patch.getSeedIndex() == 41 ? "leaf " : ""; Event harvestingFruitEvent = new Event(800); harvestingFruitEvent.setAction(() => { harvestingFruitEvent.stop(); p.getPackets().sendMessage("You pick " + (string)SEEDS[patch.getSeedIndex()][9] + " " + (string)SEEDS[patch.getSeedIndex()][7] + s + " from the tree."); p.getSkills().addXp(Skills.SKILL.FARMING, (double)SEEDS[patch.getSeedIndex()][8]); p.getInventory().addItemOrGround((int)SEEDS[patch.getSeedIndex()][2], 1); patch.setStatus(patch.getStatus() - 1); if (patch.getStatus() == 5) // We have taken all the fruit (it is 5 after we lower the status above) { patch.setStatus(13); // Chop option p.removeTemporaryAttribute("unmovable"); patch.setWeeding(false); } setConfig(p, patch); }); Server.registerEvent(harvestingFruitEvent); }); Server.registerEvent(harvestFruitEvent); }
public static void growPatch(Patch patch) { if (patch.isTree()) { if (patch.getStatus() == patch.checkHealthStatus()) { if (!patch.isHealthChecked()) { return; } } else if (patch.getStatus() == patch.chopStatus()) { return; } else if (patch.getStatus() == patch.stumpStatus()) { patch.setStatus(patch.chopStatus()); } else { patch.setStatus(patch.getStatus() + 1); } } else if (patch.isFruitTree()) { if (patch.isWeeding()) { return; } if (patch.getStatus() == patch.checkHealthStatus()) { if (!patch.isHealthChecked()) { return; } } if (patch.isHealthChecked()) { if (patch.getStatus() == patch.checkHealthStatus() - 1) // all fruit { return; } } if (patch.getStatus() == patch.stumpStatus()) { patch.setStatus(patch.chopStatus()); } else if (patch.getStatus() == patch.chopStatus()) { patch.setStatus(6); } else { patch.setStatus(patch.getStatus() + 1); } } else { patch.setStatus(patch.getStatus() + 1); } Player owner = Server.getPlayerForName(patch.getOwnerName()); if (owner != null) { setConfig(owner, patch); } patch.setLastUpdate(Environment.TickCount); }