public static void chopTendrils(Player p, int x, int y) { int var = x == 3057 ? x + 2 : x - 1; AreaEvent chopTendrilsAreaEvent = new AreaEvent(p, var, y, var, y + 2); chopTendrilsAreaEvent.setAction(() => { if (!Woodcutting.hasAxe(p)) { p.getPackets().sendMessage("You need an axe to get past this obstacle."); return; } p.getWalkingQueue().resetWalkingQueue(); p.setFaceLocation(new Location(x + 1, y, 0)); p.setLastAnimation(new Animation(Woodcutting.getAxeAnimation(p))); p.setTemporaryAttribute("unmovable", true); Event chopTendrilsEvent = new Event(1900); chopTendrilsEvent.setAction(() => { int status = 0; int[] TENDRILS = { 7161, 7162, 7163 }; if (status < 3) { p.getPackets().createObject(TENDRILS[status], new Location(x, y, 0), x == 3057 ? 3 : 1, 10); } status++; if (status == 1) { p.setLastAnimation(new Animation(Woodcutting.getAxeAnimation(p))); chopTendrilsEvent.setTick(1300); } if (status == 3) { p.getPackets().sendMessage("You clear your way through the tendrils."); p.setLastAnimation(new Animation(65535)); chopTendrilsEvent.setTick(800); } if (status == 4) { chopTendrilsEvent.stop(); teleportPastObstacle(p); p.removeTemporaryAttribute("unmovable"); } }); Server.registerEvent(chopTendrilsEvent); return; }); Server.registerCoordinateEvent(chopTendrilsAreaEvent); }
private static void chopFruitTree(Player p, Patch patch) { if (!Woodcutting.hasAxe(p)) { p.getPackets().sendMessage("You don't have an axe."); return; } patch.setWeeding(true); // prevents it from growing which makes me rage p.setLastAnimation(new Animation(Woodcutting.getAxeAnimation(p))); p.setTemporaryAttribute("harvesting", true); Event chopFruitTreeEvent = new Event(2550); chopFruitTreeEvent.setAction(() => { if (p.getTemporaryAttribute("harvesting") != null) { patch.setStatus(patch.stumpStatus()); setConfig(p, patch); } chopFruitTreeEvent.stop(); patch.setWeeding(false); }); Server.registerEvent(chopFruitTreeEvent); }
private static void chopTree(Player p, Patch patch) { if (patch.isFruitTree()) { chopFruitTree(p, patch); return; } if (!Woodcutting.hasAxe(p)) { p.getPackets().sendMessage("You don't have an axe."); return; } if (!hasLevelToCutTree(p, patch)) { p.getPackets().sendMessage("You will recieve no logs from this tree, due to your Woodcutting level."); } Tree newTree = new Tree(0, 0, null, (int)SEEDS[patch.getSeedIndex()][2], 0, (string)SEEDS[patch.getSeedIndex()][7], (double)SEEDS[patch.getSeedIndex()][11], 0); p.setTemporaryAttribute("cuttingTree", newTree); p.setLastAnimation(new Animation(Woodcutting.getAxeAnimation(p))); p.getPackets().sendMessage("You begin to swing your axe at the tree.."); long delay = getCutTime(p, patch); bool canRecieveLog = hasLevelToCutTree(p, patch); Event chopTreeEvent = new Event(delay); chopTreeEvent.setAction(() => { long timeSinceLastAnimation = Environment.TickCount; if (!Woodcutting.hasAxe(p)) { p.getPackets().sendMessage("You don't have an axe."); Woodcutting.resetWoodcutting(p); chopTreeEvent.stop(); return; } if (p.getTemporaryAttribute("cuttingTree") == null) { Woodcutting.resetWoodcutting(p); chopTreeEvent.stop(); return; } Tree tree = (Tree)p.getTemporaryAttribute("cuttingTree"); if (!newTree.Equals(tree)) { chopTreeEvent.stop(); return; } if (canRecieveLog) { string s = tree.getLog() == 1521 ? "an" : "a"; if (p.getInventory().addItem(tree.getLog())) { p.getSkills().addXp(Skills.SKILL.WOODCUTTING, tree.getXp()); p.getPackets().sendMessage("You cut down " + s + " " + tree.getName() + " log."); } else { p.getPackets().sendChatboxInterface(210); p.getPackets().modifyText("Your inventory is too full to carry any logs.", 210, 1); p.setLastAnimation(new Animation(65535)); chopTreeEvent.stop(); return; } } if (misc.random(canRecieveLog ? 2 : 0) == 0) { p.setLastAnimation(new Animation(65535)); patch.setStatus(patch.getConfigLength() - 1); setConfig(p, patch); chopTreeEvent.stop(); return; } if (Environment.TickCount - timeSinceLastAnimation >= 2550) { p.setLastAnimation(new Animation(Woodcutting.getAxeAnimation(p))); timeSinceLastAnimation = Environment.TickCount; } }); Server.registerEvent(chopTreeEvent); }