Esempio n. 1
0
 private static bool hasLevelToCutTree(Player p, Patch patch)
 {
     if (patch.isFruitTree())
     {
         return(true);
     }
     return(p.getSkills().getGreaterLevel(Skills.SKILL.WOODCUTTING) >= (int)SEEDS[patch.getSeedIndex()][10]);
 }
Esempio n. 2
0
 private static void checkTreeHealth(Player p, Patch patch)
 {
     patch.setHealthChecked(true);
     if (patch.isFruitTree())
     {
         patch.setStatus(11);
     }
     else
     {
         patch.setStatus(patch.getConfigLength() - 2);
     }
     p.getPackets().sendMessage("You check the health of the tree.");
     setConfig(p, patch);
     p.getSkills().addXp(Skills.SKILL.FARMING, (double)SEEDS[patch.getSeedIndex()][5]);
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }