コード例 #1
0
ファイル: Farming.cs プロジェクト: Rut0/RSPS-CSharp
        private static void digUpTree(Player p, Patch patch)
        {
            p.setLastAnimation(new Animation(830));
            Event digUpTreeEvent = new Event(1000);

            digUpTreeEvent.setAction(() =>
            {
                patch.setStatus(2);
                patch.setConfigArray(WEEDS_CONFIG);
                setConfig(p, patch);
                p.getPackets().sendMessage("You dig up the tree.");
                digUpTreeEvent.stop();
            });
            Server.registerEvent(digUpTreeEvent);
        }
コード例 #2
0
ファイル: Farming.cs プロジェクト: Rut0/RSPS-CSharp
 private static void plantCrop(Player p, Patch patch, int seedId)
 {
     if (p.getTemporaryAttribute("unmovable") != null)
     {
         return;
     }
     for (int i = 0; i < SEEDS.Length; i++)
     {
         if (seedId == (int)SEEDS[i][1])
         {
             PatchType type    = patch.getPatchType();
             bool      sapling = type.Equals(PatchType.TREE) || type.Equals(PatchType.FRUIT_TREE);
             string    s       = sapling ? "sapling" : "seeds.";
             string    s1      = s.Equals("sapling") ? patch.getSeedIndex() == 33 || patch.getSeedIndex() == 38 || patch.getSeedIndex() == 40 ? "an " : "a " : "";
             if (!patch.getPatchType().Equals(PatchType.VEGATABLE) && !patch.getPatchType().Equals(PatchType.VEGATABLE_1))
             {
                 if (!patch.getPatchType().Equals((PatchType)SEEDS[i][0]))
                 {
                     string s2 = !((PatchType)SEEDS[i][0]).Equals(PatchType.FRUIT_TREE) && !((PatchType)SEEDS[i][0]).Equals(PatchType.TREE) ? "seed" : "tree";
                     p.getPackets().sendMessage("This type of " + s2 + " cannot be planted here.");
                     return;
                 }
             }
             else if (patch.getPatchType().Equals(PatchType.VEGATABLE) || patch.getPatchType().Equals(PatchType.VEGATABLE_1))
             {
                 if (!SEEDS[i][0].Equals(PatchType.VEGATABLE) && !SEEDS[i][0].Equals(PatchType.VEGATABLE_1))
                 {
                     p.getPackets().sendMessage("This type of seed  cannot be planted here.");
                     return;
                 }
             }
             int[] data = getDataForPatch(patch, i);
             if (data == null)
             {
                 return;
             }
             patch.setSeedIndex(i);
             if (p.getSkills().getGreaterLevel(Skills.SKILL.FARMING) < (int)SEEDS[patch.getSeedIndex()][6])
             {
                 p.getPackets().sendMessage("You need a Farming level of " + (int)SEEDS[patch.getSeedIndex()][6] + " to plant " + s1 + "" + (string)SEEDS[patch.getSeedIndex()][7] + " seeds.");
                 return;
             }
             int seedAmount = (int)PATCHES[patch.getPatchIndex()][8];
             if (!p.getInventory().hasItemAmount((int)SEEDS[i][1], seedAmount))
             {
                 p.getPackets().sendMessage("This patch requires " + seedAmount + " seeds.");
                 return;
             }
             if (!sapling)
             {
                 if (!p.getInventory().hasItem(TOOLS[1]))
                 {
                     p.getPackets().sendMessage("You need a seed dibber to plant seeds.");
                     return;
                 }
             }
             else
             {
                 if (!p.getInventory().hasItem(TOOLS[2]))
                 {
                     p.getPackets().sendMessage("You need a trowel to transfer the sapling from the pot to a farming patch.");
                     return;
                 }
                 if (!p.getInventory().hasItem(TOOLS[3]))
                 {
                     p.getPackets().sendMessage("You need a spade to plant the salping.");
                     return;
                 }
             }
             int j = i;
             p.setLastAnimation(new Animation(2291));
             p.setTemporaryAttribute("unmovable", true);
             Event plantCropEvent = new Event(1000);
             plantCropEvent.setAction(() =>
             {
                 plantCropEvent.stop();
                 if (p.getInventory().deleteItem((int)SEEDS[j][1], seedAmount))
                 {
                     if (sapling)
                     {
                         p.getInventory().addItemOrGround(TOOLS[4]);
                     }
                     patch.setStatus(0);
                     patch.setConfigArray(data);
                     patch.setTimeToGrow((long)SEEDS[j][3]);
                     setConfig(p, patch);
                     p.removeTemporaryAttribute("unmovable");
                     string prefix = seedAmount > 1 ? "" + seedAmount : "a";
                     string suffix = seedAmount > 1 ? "seeds." : "seed.";
                     if ((patch.getPatchType().Equals(PatchType.HERB) && (patch.getSeedIndex() == 20 || patch.getSeedIndex() == 21)))
                     {
                         prefix = "an";
                     }
                     string message = sapling ? "You plant the " + (string)SEEDS[patch.getSeedIndex()][7] + " sapling." : "You plant " + prefix + " " + (string)SEEDS[patch.getSeedIndex()][7] + " " + suffix;
                     p.getPackets().sendMessage(message);
                     p.getSkills().addXp(Skills.SKILL.FARMING, (double)SEEDS[patch.getSeedIndex()][4]);
                 }
             });
             Server.registerEvent(plantCropEvent);
             break;
         }
     }
 }
コード例 #3
0
ファイル: Farming.cs プロジェクト: ramatronics/rsps
 private static void plantCrop(Player p, Patch patch, int seedId)
 {
     if (p.getTemporaryAttribute("unmovable") != null)
     {
         return;
     }
     for (int i = 0; i < SEEDS.Length; i++)
     {
         if (seedId == (int)SEEDS[i][1])
         {
             PatchType type = patch.getPatchType();
             bool sapling = type.Equals(PatchType.TREE) || type.Equals(PatchType.FRUIT_TREE);
             string s = sapling ? "sapling" : "seeds.";
             string s1 = s.Equals("sapling") ? patch.getSeedIndex() == 33 || patch.getSeedIndex() == 38 || patch.getSeedIndex() == 40 ? "an " : "a " : "";
             if (!patch.getPatchType().Equals(PatchType.VEGATABLE) && !patch.getPatchType().Equals(PatchType.VEGATABLE_1))
             {
                 if (!patch.getPatchType().Equals((PatchType)SEEDS[i][0]))
                 {
                     string s2 = !((PatchType)SEEDS[i][0]).Equals(PatchType.FRUIT_TREE) && !((PatchType)SEEDS[i][0]).Equals(PatchType.TREE) ? "seed" : "tree";
                     p.getPackets().sendMessage("This type of " + s2 + " cannot be planted here.");
                     return;
                 }
             }
             else if (patch.getPatchType().Equals(PatchType.VEGATABLE) || patch.getPatchType().Equals(PatchType.VEGATABLE_1))
             {
                 if (!SEEDS[i][0].Equals(PatchType.VEGATABLE) && !SEEDS[i][0].Equals(PatchType.VEGATABLE_1))
                 {
                     p.getPackets().sendMessage("This type of seed  cannot be planted here.");
                     return;
                 }
             }
             int[] data = getDataForPatch(patch, i);
             if (data == null)
             {
                 return;
             }
             patch.setSeedIndex(i);
             if (p.getSkills().getGreaterLevel(Skills.SKILL.FARMING) < (int)SEEDS[patch.getSeedIndex()][6])
             {
                 p.getPackets().sendMessage("You need a Farming level of " + (int)SEEDS[patch.getSeedIndex()][6] + " to plant " + s1 + "" + (string)SEEDS[patch.getSeedIndex()][7] + " seeds.");
                 return;
             }
             int seedAmount = (int)PATCHES[patch.getPatchIndex()][8];
             if (!p.getInventory().hasItemAmount((int)SEEDS[i][1], seedAmount))
             {
                 p.getPackets().sendMessage("This patch requires " + seedAmount + " seeds.");
                 return;
             }
             if (!sapling)
             {
                 if (!p.getInventory().hasItem(TOOLS[1]))
                 {
                     p.getPackets().sendMessage("You need a seed dibber to plant seeds.");
                     return;
                 }
             }
             else
             {
                 if (!p.getInventory().hasItem(TOOLS[2]))
                 {
                     p.getPackets().sendMessage("You need a trowel to transfer the sapling from the pot to a farming patch.");
                     return;
                 }
                 if (!p.getInventory().hasItem(TOOLS[3]))
                 {
                     p.getPackets().sendMessage("You need a spade to plant the salping.");
                     return;
                 }
             }
             int j = i;
             p.setLastAnimation(new Animation(2291));
             p.setTemporaryAttribute("unmovable", true);
             Event plantCropEvent = new Event(1000);
             plantCropEvent.setAction(() =>
             {
                 plantCropEvent.stop();
                 if (p.getInventory().deleteItem((int)SEEDS[j][1], seedAmount))
                 {
                     if (sapling)
                     {
                         p.getInventory().addItemOrGround(TOOLS[4]);
                     }
                     patch.setStatus(0);
                     patch.setConfigArray(data);
                     patch.setTimeToGrow((long)SEEDS[j][3]);
                     setConfig(p, patch);
                     p.removeTemporaryAttribute("unmovable");
                     string prefix = seedAmount > 1 ? "" + seedAmount : "a";
                     string suffix = seedAmount > 1 ? "seeds." : "seed.";
                     if ((patch.getPatchType().Equals(PatchType.HERB) && (patch.getSeedIndex() == 20 || patch.getSeedIndex() == 21)))
                     {
                         prefix = "an";
                     }
                     string message = sapling ? "You plant the " + (string)SEEDS[patch.getSeedIndex()][7] + " sapling." : "You plant " + prefix + " " + (string)SEEDS[patch.getSeedIndex()][7] + " " + suffix;
                     p.getPackets().sendMessage(message);
                     p.getSkills().addXp(Skills.SKILL.FARMING, (double)SEEDS[patch.getSeedIndex()][4]);
                 }
             });
             Server.registerEvent(plantCropEvent);
             break;
         }
     }
 }
コード例 #4
0
ファイル: Farming.cs プロジェクト: ramatronics/rsps
 private static void harvestCrop(Player p, Patch patch)
 {
     if (patch.getPatchType().Equals(PatchType.VEGATABLE) || patch.getPatchType().Equals(PatchType.VEGATABLE_1))
     {
         if (!p.getInventory().hasItem(TOOLS[3]))
         {
             p.getPackets().sendMessage("You need a spade to harvest your crops.");
             return;
         }
     }
     PatchType patchType = patch.getPatchType();
     int emote = (patchType.Equals(PatchType.HERB) || patchType.Equals(PatchType.FLOWER)) ? 2282 : 830;
     int delay = patchType.Equals(PatchType.HERB) ? 2250 : 1500;
     int amount = patchType.Equals(PatchType.FLOWER) ? 1 : (int)PATCHES[patch.getPatchIndex()][8] + Misc.random(10);
     string s = patchType.Equals(PatchType.FLOWER) ? "flower patch" : patchType.Equals(PatchType.HERB) ? "herb patch" : "allotment";
     string s1 = patchType.Equals(PatchType.FLOWER) || patchType.Equals(PatchType.HERB) ? "pick" : "harvest";
     p.setLastAnimation(new Animation(emote));
     p.setTemporaryAttribute("harvesting", true);
     Event startHarvestCropEvent = new Event(delay);
     startHarvestCropEvent.setAction(() =>
     {
         int i = 1;
         if (p.getTemporaryAttribute("harvesting") == null)
         {
             startHarvestCropEvent.stop();
             return;
         }
         p.setLastAnimation(new Animation(emote));
         Event doHarvestCropEvent = new Event(800);
         doHarvestCropEvent.setAction(() =>
         {
             doHarvestCropEvent.stop();
             p.getSkills().addXp(Skills.SKILL.FARMING, (double)SEEDS[patch.getSeedIndex()][5]);
             p.getInventory().addItemOrGround((int)SEEDS[patch.getSeedIndex()][2], 1);
             p.getPackets().sendMessage("You " + s1 + " " + (string)SEEDS[patch.getSeedIndex()][8] + " " + (string)SEEDS[patch.getSeedIndex()][7] + " from the " + s + " .");
             if (i++ >= amount)
             {
                 p.getPackets().sendMessage("The patch has been cleared.");
                 patch.setStatus(2);
                 patch.setConfigArray(WEEDS_CONFIG);
                 setConfig(p, patch);
             }
         });
         Server.registerEvent(doHarvestCropEvent);
         if (i >= amount)
         {
             startHarvestCropEvent.stop();
             return;
         }
     });
     Server.registerEvent(startHarvestCropEvent);
 }
コード例 #5
0
ファイル: Farming.cs プロジェクト: ramatronics/rsps
 private static void digUpTree(Player p, Patch patch)
 {
     p.setLastAnimation(new Animation(830));
     Event digUpTreeEvent = new Event(1000);
     digUpTreeEvent.setAction(() =>
     {
         patch.setStatus(2);
         patch.setConfigArray(WEEDS_CONFIG);
         setConfig(p, patch);
         p.getPackets().sendMessage("You dig up the tree.");
         digUpTreeEvent.stop();
     });
     Server.registerEvent(digUpTreeEvent);
 }
コード例 #6
0
ファイル: Farming.cs プロジェクト: ramatronics/rsps
 protected static void tendToPatch(Player p, Location patchLocation, int item, int i)
 {
     Patch patch = null;
     i = getPatchIndex(patchLocation, i);
     if (i == -1)
     {
         return;
     }
     patch = Server.getGlobalObjects().getFarmingPatches().patchExists(p, i);
     if (patch == null)
     {
         patch = new Patch(p.getLoginDetails().getUsername(), (PatchType)PATCHES[i][0], i, (int)PATCHES[i][7], (int)PATCHES[i][6]);
         patch.setConfigArray(WEEDS_CONFIG);
         Server.getGlobalObjects().getFarmingPatches().addPatch(patch);
         rakePatch(p, patch);
     }
     else
     {
         if (!patch.patchOccupied() && (item == -1 || item == TOOLS[0]))
         {
             rakePatch(p, patch);
         }
         else if (patch.isBlankPatch() && item != -1)
         {
             plantCrop(p, patch, item);
         }
         else if (patch.isFullyGrown() && (item == -1 || item == TOOLS[3]))
         {
             harvestCrop(p, patch);
         }
         else if (patch.isFruitTree() && patch.getStatus() >= 6 && patch.getStatus() <= 11)
         {
             harvestFruit(p, patch);
         }
         else if ((patch.isTree() || patch.isFruitTree()) && patch.getStatus() == patch.checkHealthStatus() && !patch.isHealthChecked())
         {
             checkTreeHealth(p, patch);
         }
         else if ((patch.isTree() || patch.isFruitTree()) && patch.getStatus() == patch.chopStatus() && patch.isHealthChecked())
         {
             chopTree(p, patch);
         }
         else if ((patch.isTree() || patch.isFruitTree()) && patch.getStatus() == patch.stumpStatus() && patch.isHealthChecked() && item == TOOLS[3])
         {
             digUpTree(p, patch);
         }
         else if (patch.isFruitTree() && patch.getStatus() == patch.stumpStatus() && !patch.isHealthChecked())
         {
             p.getPackets().sendMessage("You must check the tree's health before you can chop it down.");
         }
         else
         {
             p.getPackets().sendMessage("Nothing interesting happens.");
         }
     }
 }