Esempio n. 1
0
        public static void enterCave(Player p)
        {
            AreaEvent enterCaveAreaEvent = new AreaEvent(p, 2438, 5168, 2439, 5168);
            enterCaveAreaEvent.setAction(() =>
            {
                /*
                 * Fight cave is 20k squares from the original place, then another (200 * playerIndex) squares west.
                 */
                Location instanceLocation = new Location((20000 + 2413) + (200 * p.getIndex()), 20000 + 5116, 0);
                p.teleport(instanceLocation);
                p.setFightCave(new FightCaveSession(p));

                Event caveNpcEvent = new Event(600);
                caveNpcEvent.setAction(() =>
                {
                    caveNpcEvent.stop();
                    p.getPackets().sendNPCHead(2617, 242, 1);
                    p.getPackets().modifyText("TzHaar-Mej-Jal", 242, 3);
                    p.getPackets().modifyText("You're on your own now, JalYt.", 242, 4);
                    p.getPackets().modifyText("Pepare to fight for your life!", 242, 5);
                    p.getPackets().animateInterface(9827, 242, 1);
                    p.getPackets().sendChatboxInterface2(242);
                });
                Server.registerEvent(caveNpcEvent);
            });
            Server.registerCoordinateEvent(enterCaveAreaEvent);
        }
Esempio n. 2
0
        public ShopManager()
        {
            if (!File.Exists(Misc.getServerPath() + @"\data\shops.xml"))
            {
                Misc.WriteError(@"Missing data\shops.xml");
                return;
            }
            try
            {
                //Deserialize text file to a new object.
                StreamReader objStreamReader = new StreamReader(Misc.getServerPath() + @"\data\shops.xml");
                XmlSerializer serializer = new XmlSerializer(typeof(List<Shop>));

                List<Shop> listShops = (List<Shop>)serializer.Deserialize(objStreamReader);
                shops = new Dictionary<int, Shop>();
                foreach (Shop shop in listShops)
                {
                    shops.Add(shop.id, shop);
                }
            }
            catch (Exception e)
            {
                Misc.WriteError((e.InnerException == null ? e.ToString() : e.InnerException.ToString()));
            }

            //shops = (Map<Integer, Shop>) XStreamUtil.getXStream().fromXML(new FileInputStream("data/shops.xml"));
            Event updateShopAmountsEvent = new Event(60000);
            updateShopAmountsEvent.setAction(() =>
            {
                updateShopAmounts();
            });
            Server.registerEvent(updateShopAmountsEvent);
            Console.WriteLine("Loaded " + shops.Count + " shops.");
        }
Esempio n. 3
0
 public static void completePotion(Player p, int amount, bool newMix)
 {
     if (newMix && p.getTemporaryAttribute("completePotion") == null)
     {
         return;
     }
     if (!newMix && p.getTemporaryAttribute("herbloreItem") == null)
     {
         return;
     }
     if (newMix)
     {
         if (p.getTemporaryAttribute("completePotion") == null)
         {
             return;
         }
         int index = (int)p.getTemporaryAttribute("completePotion");
         p.setTemporaryAttribute("herbloreItem", new Potion(END_POTION[index], UNFINISHED[index], SECONDARY[index], POTION_LEVEL[index], POTION_XP[index], amount));
     }
     Potion item = (Potion)p.getTemporaryAttribute("herbloreItem");
     if (item == null || p == null || item.getAmount() <= 0)
     {
         resetAllHerbloreVariables(p);
         return;
     }
     if (!p.getInventory().hasItem(item.getSecondary()) || !p.getInventory().hasItem(item.getUnfinished()))
     {
         resetAllHerbloreVariables(p);
         return;
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.HERBLORE) < item.getLevel())
     {
         p.getPackets().sendMessage("You need a Herblore level of " + item.getLevel() + " to make that potion.");
         resetAllHerbloreVariables(p);
         return;
     }
     string s = ItemData.forId(item.getFinished()).getName().Replace("(3)", "");
     if (p.getInventory().deleteItem(item.getUnfinished()) && p.getInventory().deleteItem(item.getSecondary()))
     {
         if (p.getInventory().addItem(item.getFinished()))
         {
             item.decreaseAmount();
             p.setLastAnimation(new Animation(MIX_ANIMATION));
             p.getSkills().addXp(Skills.SKILL.HERBLORE, item.getXp());
             p.getPackets().sendMessage("You add the ingredient into the murky vial, you have completed the potion.");
             p.getPackets().closeInterfaces();
         }
     }
     if (item.getAmount() >= 1)
     {
         Event completeMorePotionsEvent = new Event(750);
         completeMorePotionsEvent.setAction(() =>
         {
             completePotion(p, item.getAmount(), false);
             completeMorePotionsEvent.stop();
         });
         Server.registerEvent(completeMorePotionsEvent);
     }
 }
Esempio n. 4
0
 public static void cutGem(Player p, int index, int amount, bool newCut)
 {
     index -= 50;
     if (newCut)
     {
         p.setTemporaryAttribute("craftItem", new CraftItem(5, index, amount, (double)GEMS[index][3], (int)GEMS[index][1], (string)GEMS[index][4], (int)GEMS[index][2]));
     }
     CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");
     if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 5)
     {
         Crafting.resetCrafting(p);
         return;
     }
     p.getPackets().closeInterfaces();
     if (!p.getInventory().hasItem(CHISEL))
     {
         p.getPackets().sendMessage("You cannot cut gems without a chisel.");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem((int)GEMS[item.getCraftItem()][0]))
     {
         if (newCut)
         {
             p.getPackets().sendMessage("You have no " + item.getMessage() + " to cut.");
         }
         else
         {
             p.getPackets().sendMessage("You have no more " + item.getMessage() + "'s to cut.");
         }
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel())
     {
         p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to cut that gem.");
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getInventory().deleteItem((int)GEMS[item.getCraftItem()][0]))
     {
         p.getInventory().addItem(item.getFinishedItem());
         p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
         p.setLastAnimation(new Animation((int)GEMS[item.getCraftItem()][5]));
         p.getPackets().sendMessage("You cut the " + item.getMessage() + ".");
     }
     item.decreaseAmount();
     if (item.getAmount() >= 1)
     {
         Event cutMoreGemEvent = new Event(1500);
         cutMoreGemEvent.setAction(() =>
         {
             cutGem(p, -1, -1, false);
             cutMoreGemEvent.stop();
         });
         Server.registerEvent(cutMoreGemEvent);
     }
 }
Esempio n. 5
0
 public static void craftClay(Player p, int amount, int craftType, int craftItem, bool newCraft)
 {
     if (newCraft)
     {
         if ((craftType != 1 && craftType != 2) || craftItem < 0 || craftItem > 4)
         {
             return;
         }
         int index = craftItem;
         int endItem = craftType == 1 ? 0 : 1;
         int xp = craftType == 1 ? 3 : 4;
         p.setTemporaryAttribute("craftItem", new CraftItem(craftType, craftItem, amount, (double)CLAY_ITEMS[index][xp], (int)CLAY_ITEMS[index][endItem], (string)CLAY_ITEMS[index][5], (int)CLAY_ITEMS[index][2]));
     }
     CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");
     if (item == null || p == null || item.getAmount() <= 0)
     {
         Crafting.resetCrafting(p);
         return;
     }
     int neededItem = item.getCraftType() == 1 ? CLAY : (int)CLAY_ITEMS[item.getCraftItem()][0];
     string s = item.getCraftType() == 1 ? "You mould the clay into a " + item.getMessage() : "You bake the " + item.getMessage() + " in the oven";
     string s1 = item.getCraftType() == 1 ? "You need some soft clay to mould a " + item.getMessage() : "You need a pre-made " + item.getMessage() + " to put in the oven";
     int animation = item.getCraftType() == 1 ? 883 : 899;
     if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel())
     {
         p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to make a " + item.getMessage() + ".");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem(neededItem))
     {
         p.getPackets().sendMessage(s1 + ".");
         Crafting.resetCrafting(p);
         return;
     }
     p.getPackets().closeInterfaces();
     if (p.getInventory().deleteItem(neededItem))
     {
         if (p.getInventory().addItem(item.getFinishedItem()))
         {
             p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
             p.getPackets().sendMessage(s + ".");
             p.setLastAnimation(new Animation(animation));
         }
     }
     item.decreaseAmount();
     if (item.getAmount() >= 1)
     {
         Event craftMoreClayEvent = new Event(1500);
         craftMoreClayEvent.setAction(() =>
         {
             craftClay(p, -1, -1, -1, false);
             craftMoreClayEvent.stop();
         });
         Server.registerEvent(craftMoreClayEvent);
     }
 }
Esempio n. 6
0
 public static void cutLog(Player p, int amount, int logType, int itemType, bool isStringing, bool newFletch)
 {
     Bow item = null;
     if (newFletch)
     {
         item = getBow(itemType, logType, amount, isStringing);
         Fletching.setFletchItem(p, item);
     }
     item = (Bow)Fletching.getFletchItem(p);
     if (item == null || p == null)
     {
         return;
     }
     bool stringing = item.isStringing();
     if (!canFletch(p, item, stringing))
     {
         p.getPackets().closeInterfaces();
         return;
     }
     int animation = getAnimation(item);
     if (!stringing)
     {
         int amt = item.getItemType() == 2 ? ARROW_AMOUNT : 1;
         if (p.getInventory().deleteItem(LOGS[item.getLogType()]))
         {
             p.getInventory().addItem(item.getFinishedItem(), amt);
             p.getSkills().addXp(Skills.SKILL.FLETCHING, item.getXp());
             item.decreaseAmount();
             p.getPackets().sendMessage("You carefully cut the wood into " + MESSAGE[item.getItemType()] + ".");
             p.setLastAnimation(new Animation(animation));
         }
     }
     else
     {
         int[] bows = item.getItemType() == 0 ? UNSTRUNG_SHORTBOW : UNSTRUNG_LONGBOW;
         if (p.getInventory().deleteItem(BOWSTRING) && p.getInventory().deleteItem(bows[item.getLogType()]))
         {
             p.getInventory().addItem(item.getFinishedItem());
             p.getSkills().addXp(Skills.SKILL.FLETCHING, item.getXp());
             item.decreaseAmount();
             p.getPackets().sendMessage("You add a string to the bow.");
             p.setLastAnimation(new Animation(animation));
         }
     }
     p.getPackets().closeInterfaces();
     if (item.getAmount() >= 1)
     {
         Event cutMoreLogsEvent = new Event(1500);
         cutMoreLogsEvent.setAction(() =>
         {
             cutLog(p, -1, -1, -1, false, false);
             cutMoreLogsEvent.stop();
         });
         Server.registerEvent(cutMoreLogsEvent);
     }
 }
Esempio n. 7
0
 public static void newSilverItem(Player p, int amount, int index, bool newCraft)
 {
     index -= 120;
     if (newCraft)
     {
         p.setTemporaryAttribute("craftItem", new CraftItem(3, index, amount, (double)SILVER_ITEMS[index][3], (int)SILVER_ITEMS[index][0], (string)SILVER_ITEMS[index][4], (int)SILVER_ITEMS[index][2]));
     }
     CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");
     if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 3)
     {
         Crafting.resetCrafting(p);
         return;
     }
     p.getPackets().closeInterfaces();
     string s = item.getCraftItem() == 0 ? "an" : "a";
     if (!p.getInventory().hasItem((int)SILVER_ITEMS[item.getCraftItem()][1]))
     {
         p.getPackets().sendMessage("You need " + s + " " + item.getMessage() + " mould to make that.");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem(SILVER_BAR))
     {
         p.getPackets().sendMessage("You don't have a Silver bar.");
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel())
     {
         p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to smelt that.");
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getInventory().deleteItem(SILVER_BAR))
     {
         p.getInventory().addItem(item.getFinishedItem());
         p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
         p.setLastAnimation(new Animation(3243));
         p.getPackets().sendMessage("You smelt the Silver bar in to " + s + " " + item.getMessage() + ".");
     }
     item.decreaseAmount();
     if (item.getAmount() >= 1)
     {
         Event makeMoreSilverItemEvent = new Event(1500);
         makeMoreSilverItemEvent.setAction(() =>
         {
             newSilverItem(p, -1, -1, false);
             makeMoreSilverItemEvent.stop();
         });
         Server.registerEvent(makeMoreSilverItemEvent);
     }
 }
Esempio n. 8
0
        // TODO make this use an AreaEvent so itll work from a distance.
        /**
         * Will fill vials in a continuous motion from a water source.
         */
        public static bool fillingVial(Player p, Location loc)
        {
            if (!p.getInventory().hasItem(VIAL) || !p.getLocation().withinDistance(loc, 2))
            {
                return true;
            }
            if (p.getTemporaryAttribute("fillVialTimer") != null)
            {
                long lastFillTime = (int)p.getTemporaryAttribute("fillVialTimer");
                if (Environment.TickCount - lastFillTime < 600)
                {
                    return true;
                }
            }
            p.setTemporaryAttribute("fillingVials", true);
            p.setFaceLocation(loc);

            Event fillVialEvent = new Event(500);
            fillVialEvent.setAction(() =>
            {
                int amountFilled = 0;
                string s = amountFilled == 1 ? "vial" : "vials";
                if (p.getTemporaryAttribute("fillingVials") == null || !p.getLocation().withinDistance(loc, 2) || !p.getInventory().hasItem(229))
                {
                    p.setLastAnimation(new Animation(65535));
                    if (amountFilled > 0)
                    {
                        p.getPackets().sendMessage("You fill up the " + s + " with water.");
                    }
                    fillVialEvent.stop();
                    return;
                }
                if (p.getInventory().replaceSingleItem(VIAL, VIAL_OF_WATER))
                {
                    p.setLastAnimation(new Animation(832));
                    amountFilled++;
                    p.setTemporaryAttribute("fillVialTimer", Environment.TickCount);
                }
                else
                {
                    if (amountFilled > 0)
                    {
                        p.setLastAnimation(new Animation(65535));
                        p.getPackets().sendMessage("You fill up the " + s + " with water.");
                    }
                    fillVialEvent.stop();
                }
            });
            Server.registerEvent(fillVialEvent);
            return true;
        }
Esempio n. 9
0
 public static void craftGlass(Player p, int amount, int index, bool newCraft)
 {
     if (newCraft)
     {
         p.setTemporaryAttribute("craftItem", new CraftItem(3, index, amount, (double)GLASS_ITEMS[index][2], (int)GLASS_ITEMS[index][0], (string)GLASS_ITEMS[index][3], (int)GLASS_ITEMS[index][1]));
     }
     CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");
     if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 3)
     {
         Crafting.resetCrafting(p);
         return;
     }
     p.getPackets().closeInterfaces();
     if (!p.getInventory().hasItem(MOLTEN_GLASS))
     {
         p.getPackets().sendMessage("You have no molten glass.");
         Crafting.resetCrafting(p);
         return;
     }
     if (!p.getInventory().hasItem(GLASSBLOWING_PIPE))
     {
         p.getPackets().sendMessage("You need a glassblowing pipe if you wish to make a glass item.");
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel())
     {
         p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to craft that item.");
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getInventory().deleteItem(MOLTEN_GLASS))
     {
         p.getInventory().addItem(item.getFinishedItem());
         p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
         p.setLastAnimation(new Animation(884));
         p.getPackets().sendMessage("You blow through the pipe, shaping the molten glass into a " + item.getMessage() + ".");
     }
     item.decreaseAmount();
     if (item.getAmount() >= 1)
     {
         Event craftMoreGlassEvent = new Event(1500);
         craftMoreGlassEvent.setAction(() =>
         {
             craftGlass(p, -1, -1, false);
             craftMoreGlassEvent.stop();
         });
         Server.registerEvent(craftMoreGlassEvent);
     }
 }
Esempio n. 10
0
        public void fireCannon()
        {
            if (firing)
            {
                loadCannon();
                return;
            }

            firing = true;
            int cannonTurnAnimation = 515;
            Event attemptFireCannonEvent = new Event(1000);
            attemptFireCannonEvent.setAction(() =>
            {
                if (!firing)
                {
                    attemptFireCannonEvent.stop();
                    return;
                }
                p.getPackets().newObjectAnimation(cannonLocation, cannonTurnAnimation);
                Event fireCannonEvent = new Event(600);
                fireCannonEvent.setAction(() =>
                {
                    if (!firing)
                    {
                        fireCannonEvent.stop();
                        return;
                    }
                    if (stopCannon && cannonTurnAnimation == 514)
                    {
                        cannonTurnAnimation = 514;
                        fireCannonEvent.stop();
                        firing = false;
                        return;
                    }
                    if (!stopCannon)
                    {
                        if (checkHitTarget())
                            checkCannonballs();
                    }
                    if (direction++ == 7)
                        direction = 0;
                    if (++cannonTurnAnimation > 521)
                        cannonTurnAnimation = 514;
                    fireCannonEvent.stop();
                });
                Server.registerEvent(fireCannonEvent);
            });
            Server.registerEvent(attemptFireCannonEvent);
        }
Esempio n. 11
0
        public GrandExchange()
        {
            buyOffers = new Dictionary<int, GEItem[]>();
            sellOffers = new Dictionary<int, GEItem[]>();

            /* Load grand exchange items */
            Console.WriteLine("Loading Grand Exchange Items");
            try
            { //TODO: Convert to ADO.NET / MDB clientside database.
                if (File.Exists(Misc.getServerPath() + @"\buyOffers.xml"))
                {
                    //Deserialize text file to a new object.
                    StreamReader objStreamReader = new StreamReader(Misc.getServerPath() + @"\buyOffers.xml");
                    XmlSerializer serializer = new XmlSerializer(typeof(GEDictionaryWrapper), new Type[] { typeof(BuyOffer) });
                    GEDictionaryWrapper geDictionaryWrapper = (GEDictionaryWrapper)serializer.Deserialize(objStreamReader);
                    objStreamReader.Close();
                    buyOffers = geDictionaryWrapper.GetMap();
                    Console.WriteLine("Loaded " + buyOffers.Count + " buy offers in Grand Exchange");
                }
                if (File.Exists(Misc.getServerPath() + @"\sellOffers.xml"))
                {
                    //Deserialize text file to a new object.
                    StreamReader objStreamReader = new StreamReader(Misc.getServerPath() + @"\sellOffers.xml");
                    XmlSerializer serializer = new XmlSerializer(typeof(GEDictionaryWrapper), new Type[] { typeof(SellOffer) });
                    GEDictionaryWrapper geDictionaryWrapper = (GEDictionaryWrapper)serializer.Deserialize(objStreamReader);
                    objStreamReader.Close();
                    sellOffers = geDictionaryWrapper.GetMap();
                    Console.WriteLine("Loaded " + sellOffers.Count + " sell offers in Grand Exchange");
                }
            }
            catch (Exception e)
            {
                Misc.WriteError(e.Message);
            }

            Event startGEEvent = new Event(5000);
            startGEEvent.setAction(() =>
            {
                processSales();
            });
            Server.registerEvent(startGEEvent);
            /*
             * This saves the grand exchange every 60 seconds.
             * Decided not to make it a event because it will impact performance when
             * grand exchange really packs up, as it does I/O operations to harddrive.
             */
            new Thread(saveGrandExchange).Start();
        }
Esempio n. 12
0
 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);
 }
Esempio n. 13
0
 public static void exitCave(Player p, int objectX, int objectY)
 {
     AreaEvent exitCaveAreaEvent = new AreaEvent(p, objectX, objectY - 1, objectX + 2, objectY - 1);
     exitCaveAreaEvent.setAction(() =>
     {
         p.setTemporaryAttribute("unmovable", true);
         Event teleFromCaveEvent = new Event(600);
         teleFromCaveEvent.setAction(() =>
         {
             teleFromCaveEvent.stop();
             p.getFightCave().teleFromCave(true);
         });
         Server.registerEvent(teleFromCaveEvent);
     });
     Server.registerCoordinateEvent(exitCaveAreaEvent);
 }
Esempio n. 14
0
 public static void createXbow(Player p, int amount, int xbowType, bool isStringing, bool newFletch)
 {
     SkillItem item = null;
     if (newFletch || Fletching.getFletchItem(p) == null)
     {
         item = getXbow(xbowType, isStringing, amount);
         Fletching.setFletchItem(p, item);
     }
     item = (SkillItem)Fletching.getFletchItem(p);
     if (item == null || p == null)
     {
         return;
     }
     bool stringing = item.getItemTwo() == XBOW_STRING ? true : false;
     if (!canFletch(p, item))
     {
         p.getPackets().closeInterfaces();
         return;
     }
     if (p.getInventory().deleteItem(item.getItemOne()) && p.getInventory().deleteItem(item.getItemTwo()))
     {
         p.getInventory().addItem(item.getFinishedItem());
         p.getSkills().addXp(Skills.SKILL.FLETCHING, item.getXp());
         item.decreaseAmount();
         p.getPackets().closeInterfaces();
         if (!stringing)
         {
             p.getPackets().sendMessage("You attach some limbs to the Crossbow.");
         }
         else
         {
             p.setLastAnimation(new Animation(6677));
             p.getPackets().sendMessage("You add a Crossbow String to the Crossbow, you have completed the " + ItemData.forId(item.getFinishedItem()).getName() + ".");
         }
     }
     if (item.getAmount() >= 1)
     {
         Event createMoreXBowEvent = new Event(1500);
         createMoreXBowEvent.setAction(() =>
         {
             createXbow(p, -1, -1, false, false);
             createMoreXBowEvent.stop();
         });
         Server.registerEvent(createMoreXBowEvent);
     }
 }
Esempio n. 15
0
 public static void craftSpinning(Player p, int amount, int index, bool newCraft)
 {
     if (newCraft)
     {
         p.setTemporaryAttribute("craftItem", new CraftItem(6, index, amount, (double)SPINNING_ITEMS[index][3], (int)SPINNING_ITEMS[index][0], (string)SPINNING_ITEMS[index][4], (int)SPINNING_ITEMS[index][2]));
     }
     CraftItem item = (CraftItem)p.getTemporaryAttribute("craftItem");
     if (item == null || p == null || item.getAmount() <= 0 || item.getCraftType() != 6)
     {
         Crafting.resetCrafting(p);
         return;
     }
     p.getPackets().closeInterfaces();
     int i = item.getCraftItem();
     if (!p.getInventory().hasItem((int)SPINNING_ITEMS[i][1]))
     {
         p.getPackets().sendMessage("You have no " + item.getMessage() + ".");
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.CRAFTING) < item.getLevel())
     {
         p.getPackets().sendMessage("You need a Crafting level of " + item.getLevel() + " to spin that.");
         Crafting.resetCrafting(p);
         return;
     }
     if (p.getInventory().deleteItem((int)SPINNING_ITEMS[i][1]))
     {
         p.getInventory().addItem(item.getFinishedItem());
         p.getSkills().addXp(Skills.SKILL.CRAFTING, item.getXp());
         p.setLastAnimation(new Animation(894));
         p.getPackets().sendMessage("You spin the " + item.getMessage() + " into a " + SPIN_FINISH[i] + ".");
     }
     item.decreaseAmount();
     if (item.getAmount() >= 1)
     {
         Event craftMoreSpinningEvent = new Event(750);
         craftMoreSpinningEvent.setAction(() =>
         {
             craftSpinning(p, -1, -1, false);
             craftMoreSpinningEvent.stop();
         });
         Server.registerEvent(craftMoreSpinningEvent);
     }
 }
Esempio n. 16
0
 public static void burnBoil(Player p, int x, int y)
 {
     AreaEvent burnBoilAreaEvent = new AreaEvent(p, x - 1, y - 1, x + 3, y + 2);
     burnBoilAreaEvent.setAction(() =>
     {
         if (!p.getInventory().hasItem(590))
         {
             p.getPackets().sendMessage("You need a tinderbox to get past this obstacle.");
             return;
         }
         p.setFaceLocation(new Location(x + 1, y, 0));
         p.setLastAnimation(new Animation(733));
         p.setTemporaryAttribute("unmovable", true);
         Event burnBoilEvent = new Event(1900);
         burnBoilEvent.setAction(() =>
         {
             int status = 0;
             int[] BOIL = { 7165, 7166, 7167 };
             if (status < 3)
             {
                 p.getPackets().createObject(BOIL[status], new Location(x, y, 0), x == 3060 ? 3 : 1, 10);
             }
             status++;
             if (status == 1)
             {
                 burnBoilEvent.setTick(1300);
             }
             if (status == 3)
             {
                 p.setLastAnimation(new Animation(65535));
                 burnBoilEvent.setTick(1000);
             }
             if (status == 4)
             {
                 burnBoilEvent.stop();
                 teleportPastObstacle(p);
                 p.removeTemporaryAttribute("unmovable");
             }
         });
         Server.registerEvent(burnBoilEvent);
         return;
     });
     Server.registerCoordinateEvent(burnBoilAreaEvent);
 }
Esempio n. 17
0
 public void processPatches()
 {
     /*
      * If something has to be removed from the ArrayList in this loop, use it.remove() not patches.remove()
      * or else we end up with a ConcurrentModificationException and it'll break out the loop :$.
      */
     Event processPatchesEvent = new Event(3000);
     processPatchesEvent.setAction(() =>
     {
         foreach (Patch patch in patches)
         {
             if (patch == null)
             {
                 removedPatches.Add(patch);
             }
             else if (patch.isSapling())
             {
                 if (Farming.growSapling(patch))
                 {
                     removedPatches.Add(patch);
                 }
             }
             else if (!patch.patchOccupied())
             {
                 if (Farming.regrowWeeds(patch))
                 { // true if we should remove from the list
                     removedPatches.Add(patch);
                 }
             }
             else if (!patch.isFullyGrown() && patch.patchOccupied())
             {
                 long currentTime = Environment.TickCount;
                 long lastUpdatedTime = patch.getLastUpdate();
                 int delay = (int)(patch.getTimeToGrow() / patch.getConfigLength());
                 //if (currentTime - lastUpdatedTime >= delay) {
                 Farming.growPatch(patch);
                 //}
             }
         }
         patches.RemoveAll(new Predicate<Patch>(delegate(Patch x) { return removedPatches.Contains(x); }));
     });
     Server.registerEvent(processPatchesEvent);
 }
Esempio n. 18
0
 public static void crossDitch(Player p, int x, int y)
 {
     if (p.getTemporaryAttribute("unmovable") != null)
     {
         return;
     }
     AreaEvent crossDitchAreaEvent = new AreaEvent(p, x, y - 1, x, y + 2);
     crossDitchAreaEvent.setAction(() =>
     {
         p.getPackets().closeInterfaces();
         p.getWalkingQueue().resetWalkingQueue();
         p.setTemporaryAttribute("unmovable", true);
         int newY = p.getLocation().getY() >= 3523 ? p.getLocation().getY() - 3 : p.getLocation().getY() + 3;
         int dir = newY == 3 ? 0 : 4;
         Location faceLocation = new Location(p.getLocation().getX(), dir == 3 ? 3523 : 3520, 0);
         p.setFaceLocation(faceLocation);
         Event crossDitchMoveEvent = new Event(500);
         crossDitchMoveEvent.setAction(() =>
         {
             crossDitchMoveEvent.stop();
             p.setLastAnimation(new Animation(6132));
             int regionX = p.getUpdateFlags().getLastRegion().getRegionX();
             int regionY = p.getUpdateFlags().getLastRegion().getRegionY();
             int lX = (p.getLocation().getX() - ((regionX - 6) * 8));
             int lY = (p.getLocation().getY() - ((regionY - 6) * 8));
             ForceMovement movement = new ForceMovement(lX, lY, lX, newY, 33, 60, dir);
             p.setForceMovement(movement);
             p.setFaceLocation(new Location(x, y, 0));
             Event crossDitchTeleportEvent = new Event(1250);
             crossDitchTeleportEvent.setAction(() =>
             {
                 crossDitchTeleportEvent.stop();
                 int playerY = p.getLocation().getY();
                 int nY = playerY >= 3523 ? 3520 : 3523;
                 p.teleport(new Location(p.getLocation().getX(), nY, 0));
                 p.removeTemporaryAttribute("unmovable");
             });
             Server.registerEvent(crossDitchTeleportEvent);
         });
         Server.registerEvent(crossDitchMoveEvent);
     });
     Server.registerCoordinateEvent(crossDitchAreaEvent);
 }
Esempio n. 19
0
 public static void createAmmo(Player p, int sets, int type, bool bolt, bool newFletch)
 {
     Ammo item = null;
     if (newFletch || Fletching.getFletchItem(p) == null)
     {
         item = getAmmo(type, bolt, sets);
         Fletching.setFletchItem(p, item);
     }
     item = (Ammo)Fletching.getFletchItem(p);
     if (item == null || p == null)
     {
         return;
     }
     if (!canFletch(p, item))
     {
         p.getPackets().closeInterfaces();
         return;
     }
     int amt = getArrowAmount(p, item);
     if (amt <= 0)
     {
         return;
     }
     if (p.getInventory().deleteItem(item.getItemOne(), amt) && p.getInventory().deleteItem(item.getItemTwo(), amt))
     {
         p.getInventory().addItem(item.getFinishedItem(), amt);
         p.getSkills().addXp(Skills.SKILL.FLETCHING, item.getXp() * amt);
         p.getPackets().sendMessage(getMessage(item, amt));
         item.decreaseAmount();
         p.getPackets().closeInterfaces();
     }
     if (item.getAmount() >= 1)
     {
         Event createMoreAmmoEvent = new Event(1500);
         createMoreAmmoEvent.setAction(() =>
         {
             createAmmo(p, -1, -1, false, false);
             createMoreAmmoEvent.stop();
         });
         Server.registerEvent(createMoreAmmoEvent);
     }
 }
Esempio n. 20
0
 public static void castCharge(Player p)
 {
     p.removeTemporaryAttribute("autoCasting");
     if (p.getSkills().getCurLevel(Skills.SKILL.MAGIC) < 80)
     {
         p.getPackets().sendMessage("You need a Magic level of 80 to cast Charge.");
         return;
     }
     if (!hasRunes(p, CHARGE_RUNES, CHARGE_RUNE_AMOUNT))
     {
         p.getPackets().sendMessage("You do not have enough runes to cast Charge.");
         return;
     }
     if (p.getTemporaryAttribute("godCharged") != null)
     {
         p.getPackets().sendMessage("You have already charged your god spells.");
         return;
     }
     if (hasGodCapeAndStaff(p))
     {
         p.getPackets().sendMessage("You must wear a God cape and wield the matching staff to cast Charge.");
         return;
     }
     if (!deleteRunes(p, CHARGE_RUNES, CHARGE_RUNE_AMOUNT))
     {
         return;
     }
     p.setTemporaryAttribute("godCharged", true);
     p.setLastGraphics(new Graphics(308, 800, 90));
     p.setLastAnimation(new Animation(811));
     p.getPackets().sendMessage("You feel charged with magical power..");
     int delay = 60000 + Misc.random(120000); //60 seconds + possible 120 seconds so, 1 minute to 2 minutes.
     Event removeGodChargeEvent = new Event(delay);
     removeGodChargeEvent.setAction(() =>
     {
         removeGodChargeEvent.stop();
         p.removeTemporaryAttribute("godCharged");
         p.getPackets().sendMessage("Your magical charge fades away.");
     });
     Server.registerEvent(removeGodChargeEvent);
 }
Esempio n. 21
0
        private static void activateObelisk(int index)
        {
            if (obeliskActivated[index])
                return;

            Location[] obeliskLocations = getLocations(index);
            for (int i = 0; i < 4; i++)
            {
                WorldObject obj = new WorldObject(OBELISK_ID[index], ACTIVATED_ID, obeliskLocations[i], 0, 10);
                obj.setSecondForm(true);
                Server.getGlobalObjects().add(obj);
                foreach (Player p in Server.getPlayerList())
                {
                    p.getPackets().createObject(ACTIVATED_ID, obeliskLocations[i], 0, 10);
                }
            }
            obeliskActivated[index] = true;
            Event activateObeliskEvent = new Event(4000 + (Misc.random(4)) * 1000);
            activateObeliskEvent.setAction(() =>
            {
                activateObeliskEvent.stop();
                int randomOb = index;
                while (randomOb == index)
                {
                    // While loop so if the random one is the same one, it picks a new one
                    randomOb = Misc.random(OBELISK_ID.Length);
                }
                int random = randomOb;
                foreach (Player p in Server.getPlayerList())
                {
                    if (p != null)
                    {
                        if (p.getLocation().inArea(OBELISK_LOCATIONS[index][0] - 2, OBELISK_LOCATIONS[index][1] - 2, OBELISK_LOCATIONS[index][0] + 2, OBELISK_LOCATIONS[index][1] + 2))
                        {
                            // TODO get the big purple graphic
                            p.setLastGraphics(new Graphics(1690));
                            p.setLastAnimation(new Animation(8939));
                            Player p2 = p;

                            Event obeliskTeleportEvent = new Event(1200);
                            obeliskTeleportEvent.setAction(() =>
                            {
                                obeliskTeleportEvent.stop();
                                p2.teleport(new Location((OBELISK_LOCATIONS[random][0] - 1) + Misc.random(2), (OBELISK_LOCATIONS[random][1] - 1) + Misc.random(2), 0));

                                Event obeliskAnimationEvent = new Event(500);
                                obeliskAnimationEvent.setAction(() =>
                                {
                                    obeliskAnimationEvent.stop();
                                    p2.setLastAnimation(new Animation(8941));
                                });
                                Server.registerEvent(obeliskAnimationEvent);
                            });
                            Server.registerEvent(obeliskTeleportEvent);
                        }
                    }
                }

                for (int i = 0; i < 4; i++)
                {
                    WorldObject obj = Server.getGlobalObjects().getObject(OBELISK_ID[index], obeliskLocations[i]);
                    Server.getGlobalObjects().restoreObject(obj);
                }
                obeliskActivated[index] = false;
            });
        }
Esempio n. 22
0
 public static void slashWeb(Player p, ushort webId, Location webLocation)
 {
     AreaEvent slashWebAreaEvent = new AreaEvent(p, webLocation.getX() - 1, webLocation.getY() - 1, webLocation.getX() + 1, webLocation.getY() + 1);
     slashWebAreaEvent.setAction(() =>
     {
         long lastSlash = 0;
         p.setFaceLocation(webLocation);
         if (p.getTemporaryAttribute("lastWebSlash") != null)
         {
             lastSlash = (int)p.getTemporaryAttribute("lastWebSlash");
         }
         if (Environment.TickCount - lastSlash <= 800)
         {
             return;
         }
         if (Server.getGlobalObjects().originalObjectExists(webId, webLocation))
         {
             p.setLastAnimation(new Animation(p.getAttackAnimation()));
             p.setTemporaryAttribute("lastWebSlash", Environment.TickCount);
             Event attemptCutWebEvent = new Event(500);
             attemptCutWebEvent.setAction(() =>
             {
                 attemptCutWebEvent.stop();
                 bool webExists = Server.getGlobalObjects().originalObjectExists(webId, webLocation);
                 Server.getGlobalObjects().lowerHealth(webId, webLocation);
                 if (Server.getGlobalObjects().originalObjectExists(webId, webLocation))
                 {
                     p.getPackets().sendMessage("You fail to cut through the web.");
                 }
                 else
                 {
                     if (webExists)
                     { // This means we slashed it, if !webExists, someone else slashed it in the last 500ms
                         p.getPackets().sendMessage("You slash through the web!");
                     }
                 }
             });
             Server.registerEvent(attemptCutWebEvent);
         }
     });
     Server.registerCoordinateEvent(slashWebAreaEvent);
 }
Esempio n. 23
0
        public static void leverTeleport(Player p, int option)
        {
            p.getPackets().closeInterfaces();
            Location teleLocation = new Location(LEVER_COORDINATES[option][0], LEVER_COORDINATES[option][1], LEVER_COORDINATES[option][2]);

            Event leverTeleportEvent = new Event(200);
            leverTeleportEvent.setAction(() =>
            {
                leverTeleportEvent.stop();
                if (p.getTemporaryAttribute("teleblocked") != null)
                {
                    p.getPackets().sendMessage("A magical force prevents you from teleporting!");
                    return;
                }
                else if ((p.getTemporaryAttribute("teleporting") != null))
                {
                    return;
                }
                p.setLastAnimation(new Animation(2140));
                p.getPackets().closeInterfaces();
                p.setTemporaryAttribute("teleporting", true);
                p.getWalkingQueue().resetWalkingQueue();
                p.getPackets().clearMapFlag();
                SkillHandler.resetAllSkills(p);
                Event levelTeleportStartEvent = new Event(700);
                levelTeleportStartEvent.setAction(() =>
                {
                    levelTeleportStartEvent.stop();
                    p.setLastAnimation(new Animation(8939, 0));
                    p.setLastGraphics(new Graphics(1576, 0));
                    Event levelTeleportFinishEvent = new Event(1800);
                    levelTeleportFinishEvent.setAction(() =>
                    {
                        levelTeleportFinishEvent.stop();
                        p.teleport(teleLocation);
                        p.setLastAnimation(new Animation(8941, 0));
                        p.setLastGraphics(new Graphics(1577, 0));
                        Teleport.resetTeleport(p);
                    });
                    Server.registerEvent(levelTeleportFinishEvent);
                });
                Server.registerEvent(levelTeleportStartEvent);
            });
            Server.registerEvent(leverTeleportEvent);
        }
Esempio n. 24
0
 public void newCannon()
 {
     setupTime = Environment.TickCount;
     Event setupNewCannonEvent = new Event(1000);
     setupNewCannonEvent.setAction(() =>
     {
         string prefixMsg = (constructionStage == 0) ? "You place the " : "You add the ";
         string suffixMsg = (constructionStage == 0) ? " on the ground." : ".";
         if (p.getInventory().deleteItem(CANNON_PIECES[constructionStage]))
         {
             p.getPackets().createObject(CANNON_OBJECTS[constructionStage], cannonLocation, 0, 10);
             p.getPackets().sendMessage(prefixMsg + CONSTRUCTION_MESSAGE[constructionStage] + suffixMsg);
             if (++constructionStage >= 4)
             {
                 constructionStage--;
                 setupNewCannonEvent.stop();
                 return;
             }
             p.setLastAnimation(new Animation(827));
         }
         else
         {
             setupNewCannonEvent.stop();
         }
     });
     Server.registerEvent(setupNewCannonEvent);
 }
Esempio n. 25
0
        private static void drinkPotion(Player p, int i, int j, int slot)
        {
            //TODO antipoisons/antifire
            int lastPotion = -1;
            int delay = 500;
            long lastDrink = 0;
            if (p.isDead() || p.getTemporaryAttribute("willDie") != null)
            {
                return;
            }
            if (p.getDuel() != null)
            {
                if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_DRINKS))
                {
                    p.getPackets().sendMessage("Drinks have been disabled for this duel!");
                    return;
                }
            }
            if (p.getTemporaryAttribute("lastDrankPotion") != null)
            {
                lastPotion = (int)p.getTemporaryAttribute("lastDrankPotion");
            }
            if (p.getTemporaryAttribute("drinkPotionTimer") != null)
            {
                lastDrink = (int)p.getTemporaryAttribute("drinkPotionTimer");
            }
            int time = (j == lastPotion) ? 1000 : 500;
            if (Environment.TickCount - lastDrink < time)
            {
                return;
            }
            p.getPackets().closeInterfaces();
            p.setTemporaryAttribute("drinkPotionTimer", Environment.TickCount);
            p.setTemporaryAttribute("lastDrankPotion", j);
            p.setTarget(null);
            p.resetCombatTurns();
            p.setEntityFocus(65535);
            p.removeTemporaryAttribute("autoCasting");

            Event drinkPotionEvent = new Event(delay);
            drinkPotionEvent.setAction(() =>
            {
                drinkPotionEvent.stop();
                if (p.isDead() || p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) <= 0)
                {
                    return;
                }
                int item = i != 0 && POTIONS[i - 1][j] != -1 ? POTIONS[i - 1][j] : 229;
                if (!p.getInventory().replaceItemSlot(POTIONS[i][j], item, slot))
                {
                    return;
                }
                string drinkPotion = ItemData.forId(POTIONS[0][j]).getName().Replace("(", "").Replace(")", "").Replace("3", "").Replace("2", "").Replace("1", "").ToLower();
                p.getPackets().sendMessage("You drink some of your " + drinkPotion + ".");
                p.getPackets().sendMessage("You have " + (i == 0 ? "no" : i.ToString()) + " doses of potion left.");
                switch (j)
                {
                    case 0: //Attack potion [+3 and 10% of max attack]
                        statBoost(p, Skills.SKILL.ATTACK, 0.10, 3, false);
                        break;

                    case 1: //Antipoison potion
                        p.setPoisonAmount(0);
                        break;

                    case 2: //Strength potion [+3 and 10% of max strength]
                        statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
                        break;

                    case 3: //Restore potion [restores randomly between 10-39 points]
                        restorePotion(p, Skills.SKILL.DEFENCE, 10, 39);
                        restorePotion(p, Skills.SKILL.ATTACK, 10, 39);
                        restorePotion(p, Skills.SKILL.STRENGTH, 10, 39);
                        restorePotion(p, Skills.SKILL.RANGE, 10, 39);
                        restorePotion(p, Skills.SKILL.HITPOINTS, 10, 39);
                        break;

                    case 4: //Energy potion [restores 20% energy]
                        double newEnergy = p.getRunEnergy() * 0.20;
                        p.setRunEnergy(((p.getRunEnergy() + (int)newEnergy >= 100) ? 100 : (p.getRunEnergy() + (int)newEnergy)));
                        break;

                    case 5: //Defence potion [Should be +3 and 10% of max defence]
                        statBoost(p, Skills.SKILL.DEFENCE, 0.10, 3, false);
                        break;

                    case 6: //Agility potion [restores 2 or 3 agility points]
                        int newAgility = Misc.random(2, 3) + p.getSkills().getCurLevel(Skills.SKILL.AGILITY);
                        if (newAgility < p.getSkills().getMaxLevel(Skills.SKILL.AGILITY))
                            p.getSkills().setCurLevel(Skills.SKILL.AGILITY, newAgility);
                        break;

                    case 7: //Combat potion [Should be 10% of attack+strength and +3 to each].
                        statBoost(p, Skills.SKILL.ATTACK, 0.10, 3, false);
                        statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
                        break;

                    case 8: //Prayer potion, [heals 7-31, formula = 7+floor(prayerlevel/4)]
                        int newPrayer = 7 + (int)Math.Floor((double)(p.getSkills().getMaxLevel(Skills.SKILL.PRAYER) / 4)) + p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
                        if (newPrayer < p.getSkills().getCurLevel(Skills.SKILL.PRAYER))
                            p.getSkills().setCurLevel(Skills.SKILL.PRAYER, newPrayer);
                        checkOverdose(p, Skills.SKILL.PRAYER);
                        break;

                    case 9: //Summoning potion [25% of players summoning + 7]
                        int newSummoning = (7 + (int)((double)p.getSkills().getMaxLevel(Skills.SKILL.SUMMONING) * 0.25)) + p.getSkills().getCurLevel(Skills.SKILL.SUMMONING);
                        if (newSummoning < p.getSkills().getCurLevel(Skills.SKILL.SUMMONING))
                            p.getSkills().setCurLevel(Skills.SKILL.SUMMONING, newSummoning);

                        statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
                        break;

                    case 10: //Super attack potion [15% of players attack + 5]
                        statBoost(p, Skills.SKILL.ATTACK, 0.15, 5, false);
                        break;

                    case 11: // super antipoison
                        p.setPoisonAmount(0);
                        p.setSuperAntipoisonCycles(20);
                        break;

                    case 12: //Fishing potion [fishing +3]
                        if (p.getSkills().getCurLevel(Skills.SKILL.FISHING) < (p.getSkills().getMaxLevel(Skills.SKILL.FISHING) + 3))
                            p.getSkills().setCurLevel(Skills.SKILL.FISHING, p.getSkills().getCurLevel(Skills.SKILL.FISHING) + 3);
                        break;

                    case 13:
                        p.setRunEnergy(p.getRunEnergy() + 20);
                        if (p.getRunEnergy() >= 100)
                        {
                            p.setRunEnergy(100);
                        }
                        break;

                    case 14: //Hunter potion [hunting + 3]
                        if (p.getSkills().getCurLevel(Skills.SKILL.HUNTER) < (p.getSkills().getMaxLevel(Skills.SKILL.HUNTER) + 3))
                            p.getSkills().setCurLevel(Skills.SKILL.HUNTER, p.getSkills().getCurLevel(Skills.SKILL.HUNTER) + 3);
                        break;

                    case 15: //Super strength [strength 15% +5]
                        statBoost(p, Skills.SKILL.STRENGTH, 0.15, 5, false);
                        break;

                    case 16: //restores all skills by 33%.
                        foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL)))
                            superRestorePotion(p, skill, 0.33);
                        break;

                    case 17://Super defence [defence 15% +5]
                        statBoost(p, Skills.SKILL.DEFENCE, 0.15, 5, false);
                        break;

                    case 18: // Antifire potion
                        p.setAntifireCycles(20);
                        break;

                    case 19: //Ranging potions
                        statBoost(p, Skills.SKILL.RANGE, 0.10, 4, false);
                        break;

                    case 20: //Magic potion.
                        if (p.getSkills().getCurLevel(Skills.SKILL.MAGIC) < (p.getSkills().getMaxLevel(Skills.SKILL.MAGIC) + 4))
                            p.getSkills().setCurLevel(Skills.SKILL.MAGIC, p.getSkills().getCurLevel(Skills.SKILL.MAGIC) + 4);
                        break;

                    case 21: //Zamorak brew potion. [Attack %20+2][Strength %12 +2][Defense -10% + -2][hitpoints -10% + 20]
                        statBoost(p, Skills.SKILL.ATTACK, 0.20, 2, false);
                        statBoost(p, Skills.SKILL.STRENGTH, 0.12, 2, false);
                        statBoost(p, Skills.SKILL.DEFENCE, 0.10, 2, true);
                        statBoost(p, Skills.SKILL.HITPOINTS, 0.10, 20, true);
                        break;

                    case 22: //Saradomin brew potion. [Hitpoints +%15][Defense +25%][Strength, Attack, Magic and Ranged -10%]
                        statBoost(p, Skills.SKILL.HITPOINTS, 0.15, 0, false);
                        statBoost(p, Skills.SKILL.DEFENCE, 0.25, 0, false);
                        statBoost(p, Skills.SKILL.STRENGTH, 0.10, 0, true);
                        statBoost(p, Skills.SKILL.ATTACK, 0.10, 0, true);
                        statBoost(p, Skills.SKILL.MAGIC, 0.10, 0, true);
                        statBoost(p, Skills.SKILL.RANGE, 0.10, 0, true);
                        break;
                }
                p.setLastAnimation(new Animation(829));
                p.getPackets().sendSkillLevels();
            });
            Server.registerEvent(drinkPotionEvent);
        }
Esempio n. 26
0
        public static void doCourse(Player p, int objectX, int objectY, object[] objectArray)
        {
            if (p.getTemporaryAttribute("unmovable") != null)
            {
                return;
            }
            int agilityStage = (int)(p.getTemporaryAttribute("agilityStage") == null ? 0 : p.getTemporaryAttribute("agilityStage"));
            switch ((int)objectArray[0])
            {
                case 2295: // Log
                    CoordinateEvent doLogCoordinateEvent = new CoordinateEvent(p, new Location((int)objectArray[3], (int)objectArray[4], 0));
                    doLogCoordinateEvent.setAction(() =>
                    {
                        shoutNPCs[0].setForceText(SHOUT_MESSAGES[0]);
                        p.getPackets().sendMessage("You walk carefully across the slippery log...");
                        bool running = p.getWalkingQueue().isRunToggled();
                        p.getWalkingQueue().setRunToggled(false);
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setTemporaryAttribute("unmovable", true);
                        p.getAppearance().setWalkAnimation(155);
                        p.getUpdateFlags().setAppearanceUpdateRequired(true);
                        p.getWalkingQueue().forceWalk(0, -7);
                        Event doLogEvent = new Event(4300);
                        doLogEvent.setAction(() =>
                        {
                            doLogEvent.stop();
                            p.getPackets().sendMessage("...and make it safely to the other side.");
                            p.removeTemporaryAttribute("unmovable");
                            p.getAppearance().setWalkAnimation(-1);
                            p.getUpdateFlags().setAppearanceUpdateRequired(true);
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                            p.getWalkingQueue().setRunToggled(running);
                        });
                        Server.registerEvent(doLogEvent);
                    });
                    Server.registerCoordinateEvent(doLogCoordinateEvent);
                    break;

                case 2285: // Net #1
                    AreaEvent doNetOneAreaEvent = new AreaEvent(p, 2471, 3426, 2476, 3426);
                    doNetOneAreaEvent.setAction(() =>
                    {
                        shoutNPCs[1].setForceText(SHOUT_MESSAGES[1]);
                        p.getPackets().sendMessage("You climb the netting...");
                        p.setLastAnimation(new Animation(828));
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() - 1, 0));
                        p.setTemporaryAttribute("unmovable", true);
                        Event doNetOneEvent = new Event(1000);
                        doNetOneEvent.setAction(() =>
                        {
                            doNetOneEvent.stop();
                            p.removeTemporaryAttribute("unmovable");
                            p.teleport(new Location(2473, p.getLocation().getY() - 2, 1));
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                        });
                        Server.registerEvent(doNetOneEvent);
                    });
                    Server.registerCoordinateEvent(doNetOneAreaEvent);
                    break;

                case 35970: // Tree climb
                    AreaEvent treeClimbAreaEvent = new AreaEvent(p, 2472, 3422, 2474, 3423);
                    treeClimbAreaEvent.setAction(() =>
                    {
                        shoutNPCs[2].setForceText(SHOUT_MESSAGES[2]);
                        p.getPackets().sendMessage("You climb the tree...");
                        p.setLastAnimation(new Animation(828));
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setFaceLocation(new Location(2473, 3422, 1));
                        p.setTemporaryAttribute("unmovable", true);
                        Event treeClimbEvent = new Event(1000);
                        treeClimbEvent.setAction(() =>
                        {
                            treeClimbEvent.stop();
                            p.getPackets().sendMessage("...to the platform above.");
                            p.removeTemporaryAttribute("unmovable");
                            p.teleport(new Location(2473, 3420, 2));
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                        });
                        Server.registerEvent(treeClimbEvent);
                    });
                    Server.registerCoordinateEvent(treeClimbAreaEvent);
                    break;

                case 2312: // Rope balance
                    CoordinateEvent ropeBalanceCoordinateEvent = new CoordinateEvent(p, new Location((int)objectArray[3], (int)objectArray[4], 2));
                    ropeBalanceCoordinateEvent.setAction(() =>
                    {
                        shoutNPCs[3].setForceText(SHOUT_MESSAGES[3]);
                        p.getPackets().sendMessage("You carefully cross the tightrope.");
                        bool running = p.getWalkingQueue().isRunToggled();
                        p.getWalkingQueue().setRunToggled(false);
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setTemporaryAttribute("unmovable", true);
                        p.getAppearance().setWalkAnimation(155);
                        p.getUpdateFlags().setAppearanceUpdateRequired(true);
                        p.getWalkingQueue().forceWalk(+6, 0);
                        Event ropeBalanceEvent = new Event(3700);
                        ropeBalanceEvent.setAction(() =>
                        {
                            ropeBalanceEvent.stop();
                            p.removeTemporaryAttribute("unmovable");
                            p.getAppearance().setWalkAnimation(-1);
                            p.getUpdateFlags().setAppearanceUpdateRequired(true);
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                            p.getWalkingQueue().setRunToggled(running);
                        });
                        Server.registerEvent(ropeBalanceEvent);
                    });
                    Server.registerCoordinateEvent(ropeBalanceCoordinateEvent);
                    break;

                case 2314: // Tree climb #2
                    AreaEvent treeclimbTwoAreaEvent = new AreaEvent(p, 2485, 3418, 2486, 3420);
                    treeclimbTwoAreaEvent.setAction(() =>
                    {
                        p.getPackets().sendMessage("You climb down the tree...");
                        p.setLastAnimation(new Animation(828));
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setFaceLocation(new Location(2486, 3419, 2));
                        p.setTemporaryAttribute("unmovable", true);
                        Event treeClimbTwoEvent = new Event(1000);
                        treeClimbTwoEvent.setAction(() =>
                        {
                            treeClimbTwoEvent.stop();
                            p.getPackets().sendMessage("You land on the ground.");
                            p.removeTemporaryAttribute("unmovable");
                            p.teleport(new Location(2486, 3420, 0));
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                        });
                        Server.registerEvent(treeClimbTwoEvent);
                    });
                    Server.registerCoordinateEvent(treeclimbTwoAreaEvent);
                    break;

                case 2286: // Net #2
                    AreaEvent doNetTwoAreaEvent = new AreaEvent(p, 2483, 3425, 2488, 3425);
                    doNetTwoAreaEvent.setAction(() =>
                    {
                        shoutNPCs[4].setForceText(SHOUT_MESSAGES[4]);
                        p.getPackets().sendMessage("You climb the netting...");
                        p.setLastAnimation(new Animation(828));
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().clearMapFlag();
                        p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() + 1, 0));
                        p.setTemporaryAttribute("unmovable", true);
                        Event doNetTwoEvent = new Event(1000);
                        doNetTwoEvent.setAction(() =>
                        {
                            doNetTwoEvent.stop();
                            p.removeTemporaryAttribute("unmovable");
                            p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() + 2, 0));
                            p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                        });
                        Server.registerEvent(doNetTwoEvent);
                    });
                    Server.registerCoordinateEvent(doNetTwoAreaEvent);
                    break;

                case 4058: // Right obstacle pipe
                    AreaEvent passRightObstraclePipeAreaEvent = new AreaEvent(p, 2486, 3430, 2488, 3431);
                    passRightObstraclePipeAreaEvent.setAction(() =>
                    {
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX + 1 && pY == objectY)
                            newMove = 1;
                        else if (pX == objectX - 1 && pY == objectY)
                            newMove = 2;
                        if (newMove > 0)
                        {
                            int path = newMove;
                            int doCourseCounter = 0;
                            Event doCourseEvent = new Event(500);
                            doCourseEvent.setAction(() =>
                            {
                                if (doCourseCounter == 0)
                                {
                                    p.getWalkingQueue().forceWalk(0, -1);
                                }
                                else if (doCourseCounter == 1)
                                {
                                    p.getWalkingQueue().forceWalk(path == 1 ? -1 : +1, 0);
                                }
                                else
                                {
                                    doCourse(p, objectX, objectY, objectArray);
                                    doCourseEvent.stop();
                                }
                                doCourseCounter++;
                            });
                            Server.registerEvent(doCourseEvent);
                            return;
                        }
                        Event squeezeIntoRightPipeEvent = new Event(0);
                        squeezeIntoRightPipeEvent.setAction(() =>
                        {
                            squeezeIntoRightPipeEvent.stop();
                            p.getPackets().sendMessage("You squeeze into the pipe...");
                            int regionX = p.getUpdateFlags().getLastRegion().getRegionX();
                            int regionY = p.getUpdateFlags().getLastRegion().getRegionY();
                            int lX = (p.getLocation().getX() - ((regionX - 6) * 8));
                            int lY = (p.getLocation().getY() - ((regionY - 6) * 8));
                            p.setForceMovement(new ForceMovement(lX, lY, lX, lY + 4, 10, 60, 0));
                            p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() + 1, 0));
                            p.setLastAnimation(new Animation(10578));
                            bool running = p.getWalkingQueue().isRunToggled();
                            p.getWalkingQueue().setRunToggled(false);
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.setTemporaryAttribute("unmovable", true);
                            int squeezeOutOfRightPipeCounter = 0;
                            Event squeezeOutOfRightPipeEvent = new Event(1150);
                            squeezeOutOfRightPipeEvent.setAction(() =>
                            {
                                if (squeezeOutOfRightPipeCounter == 0)
                                {
                                    p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() + 3, 0));
                                    squeezeOutOfRightPipeEvent.setTick(450);
                                    squeezeOutOfRightPipeCounter++;
                                    return;
                                }
                                else if (squeezeOutOfRightPipeCounter == 1)
                                {
                                    p.setForceMovement(new ForceMovement(lX, lY + 3, lX, lY + 6, 10, 60, 0));
                                    squeezeOutOfRightPipeEvent.setTick(900);
                                    squeezeOutOfRightPipeCounter++;
                                }
                                else if (squeezeOutOfRightPipeCounter == 2)
                                {
                                    squeezeOutOfRightPipeEvent.setTick(500);
                                    p.setLastAnimation(new Animation(10579));
                                    p.setForceMovement(new ForceMovement(lX, lY + 6, lX, lY + 7, 10, 40, 0));
                                    squeezeOutOfRightPipeCounter++;
                                }
                                else
                                {
                                    p.getPackets().sendMessage("...You squeeze out of the pipe.");
                                    squeezeOutOfRightPipeEvent.stop();
                                    p.removeTemporaryAttribute("unmovable");
                                    p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                    p.getWalkingQueue().setRunToggled(running);
                                    p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() + 5, 0));
                                }
                            });
                            Server.registerEvent(squeezeOutOfRightPipeEvent);
                        });
                        Server.registerEvent(squeezeIntoRightPipeEvent);
                    });
                    Server.registerCoordinateEvent(passRightObstraclePipeAreaEvent);
                    break;

                case 154: // Left obstacle pipe
                    AreaEvent passLeftObstraclePipeAreaEvent = new AreaEvent(p, 2483, 3430, 2485, 3431);
                    passLeftObstraclePipeAreaEvent.setAction(() =>
                    {
                        int newMove = 0;
                        int pX = p.getLocation().getX();
                        int pY = p.getLocation().getY();
                        if (pX == objectX + 1 && pY == objectY)
                            newMove = 1;
                        else if (pX == objectX - 1 && pY == objectY)
                            newMove = 2;
                        else if (pX == 2483)
                            newMove = 3;
                        else if (pX == 2485)
                            newMove = 4;
                        if (newMove > 0)
                        {
                            int path = newMove;
                            int doCourseCounter = 0;
                            Event doCourseEvent = new Event(500);
                            doCourseEvent.setAction(() =>
                            {
                                if (path == 3 || path == 4)
                                {
                                    p.getWalkingQueue().forceWalk(path == 3 ? +1 : -1, 0);
                                    doCourseCounter = 2;
                                }
                                if (doCourseCounter == 0)
                                {
                                    p.getWalkingQueue().forceWalk(0, -1);
                                }
                                else if (doCourseCounter == 1)
                                {
                                    p.getWalkingQueue().forceWalk(path == 1 ? -1 : +1, 0);
                                }
                                else
                                {
                                    doCourse(p, objectX, objectY, objectArray);
                                    doCourseEvent.stop();
                                }
                                doCourseCounter++;
                            });
                            Server.registerEvent(doCourseEvent);
                            return;
                        }
                        Event squeezeIntoLeftPipeEvent = new Event(0);
                        squeezeIntoLeftPipeEvent.setAction(() =>
                        {
                            squeezeIntoLeftPipeEvent.stop();
                            p.getPackets().sendMessage("You squeeze into the pipe...");
                            int regionX = p.getUpdateFlags().getLastRegion().getRegionX();
                            int regionY = p.getUpdateFlags().getLastRegion().getRegionY();
                            int lX = (p.getLocation().getX() - ((regionX - 6) * 8));
                            int lY = (p.getLocation().getY() - ((regionY - 6) * 8));
                            p.setForceMovement(new ForceMovement(lX, lY, lX, lY + 3, 10, 60, 0));
                            p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() + 1, 0));
                            p.setLastAnimation(new Animation(10578));
                            bool running = p.getWalkingQueue().isRunToggled();
                            p.getWalkingQueue().setRunToggled(false);
                            p.getWalkingQueue().resetWalkingQueue();
                            p.getPackets().clearMapFlag();
                            p.setTemporaryAttribute("unmovable", true);
                            int squeezeOutOfLeftPipeCounter = 0;
                            Event squeezeOutOfLeftPipeEvent = new Event(1150);
                            squeezeOutOfLeftPipeEvent.setAction(() =>
                            {
                                if (squeezeOutOfLeftPipeCounter == 0)
                                {
                                    p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() + 3, 0));
                                    squeezeOutOfLeftPipeEvent.setTick(450);
                                    squeezeOutOfLeftPipeCounter++;
                                    return;
                                }
                                else if (squeezeOutOfLeftPipeCounter == 1)
                                {
                                    p.setForceMovement(new ForceMovement(lX, lY + 3, lX, lY + 6, 10, 60, 0));
                                    squeezeOutOfLeftPipeEvent.setTick(900);
                                    squeezeOutOfLeftPipeCounter++;
                                }
                                else if (squeezeOutOfLeftPipeCounter == 2)
                                {
                                    squeezeOutOfLeftPipeEvent.setTick(500);
                                    p.setLastAnimation(new Animation(10579));
                                    p.setForceMovement(new ForceMovement(lX, lY + 6, lX, lY + 7, 10, 40, 0));
                                    squeezeOutOfLeftPipeCounter++;
                                }
                                else
                                {
                                    p.getPackets().sendMessage("...You squeeze out of the pipe.");
                                    squeezeOutOfLeftPipeEvent.stop();
                                    p.removeTemporaryAttribute("unmovable");
                                    p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
                                    p.getWalkingQueue().setRunToggled(running);
                                    p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() + 5, 0));
                                }
                            });
                            Server.registerEvent(squeezeOutOfLeftPipeEvent);
                        });
                        Server.registerEvent(squeezeIntoLeftPipeEvent);
                    });
                    Server.registerCoordinateEvent(passLeftObstraclePipeAreaEvent);
                    break;
            }
        }
Esempio n. 27
0
        private static void eatFood(Player p, int i, int j, int slot)
        {
            //delay at which you eat food 0.5 seconds (half a second per eat).
            int delay = 500;
            //If you are dead or yourHp is zero (this should be enough), also if variable is set to die from next attack
            if (p.isDead() || p.getHp() <= 0 || p.getTemporaryAttribute("willDie") != null)
                return;

            //Last time you ate timer was previously set.
            if (p.getTemporaryAttribute("eatFoodTimer") != null)
            {
                //Check if the timer has passed the time of 1.2 seconds
                if (Environment.TickCount - (int)p.getTemporaryAttribute("eatFoodTimer") < 1200)
                {
                    return;
                }
            }
            //if you are in a duel
            if (p.getDuel() != null)
            {
                //dueling with No Food rule enabled
                if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_FOOD))
                {
                    p.getPackets().sendMessage("Food has been disabled for this duel!");
                    return;
                }
            }
            //Set timer right now because you are eating some food.
            p.setTemporaryAttribute("eatFoodTimer", Environment.TickCount);
            //while you are eating the target you are attacking gets reset.
            p.setTarget(null);
            p.resetCombatTurns();
            p.setEntityFocus(65535);
            p.getPackets().closeInterfaces();
            p.removeTemporaryAttribute("autoCasting");

            //start eating the food at delay which is 0.5 of a second / half a second.
            Event eatFoodEvent = new Event(delay);
            eatFoodEvent.setAction(() =>
            {
                //make the food eating event stop after this time.
                eatFoodEvent.stop();
                //if you are dead or your hp is zero aka dead.
                if (p.isDead() || p.getHp() <= 0)
                {
                    return;
                }
                int newHealth = p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) + FOOD_HEAL[j];
                int item = i != 2 && FOOD[i + 1][j] != -1 ? FOOD[i + 1][j] : -1;
                if (!p.getInventory().replaceItemSlot(FOOD[i][j], item, slot))
                {
                    return;
                }
                p.getPackets().sendMessage("You eat the " + ItemData.forId(FOOD[i][j]).getName().ToLower() + ".");
                p.getSkills().setCurLevel(Skills.SKILL.HITPOINTS, newHealth > p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS) ? p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS) : newHealth);
                p.setLastAnimation(new Animation(829));
                p.getPackets().sendSkillLevel(Skills.SKILL.HITPOINTS);
            });
            Server.registerEvent(eatFoodEvent);
        }
Esempio n. 28
0
        public static void teleportToPatch(Player p, int option)
        {
            p.setTemporaryAttribute("unmovable", true);
            p.getWalkingQueue().resetWalkingQueue();
            p.getPackets().softCloseInterfaces();
            p.getPackets().displayInterface(120);

            Event teleportToPatchEvent = new Event(2000);
            int teleportToPatchCounter = 0;
            teleportToPatchEvent.setAction(() =>
            {
                if (teleportToPatchCounter == 0)
                {
                    teleportToPatchCounter++;
                    teleportToPatchEvent.setTick(600);
                    p.teleport(new Location((int)PATCHES[option][0] + Misc.random((int)PATCHES[option][2]), (int)PATCHES[option][1] + Misc.random((int)PATCHES[option][3]), 0));
                }
                else
                {
                    teleportToPatchEvent.stop();
                    p.removeTemporaryAttribute("unmovable");
                    p.getPackets().sendMessage("You are teleported to the " + PATCHES[option][4] + ".");
                    p.getPackets().closeInterfaces();
                }
            });
        }
Esempio n. 29
0
        protected bool checkHitTarget()
        {
            int cannonX = fakeCannonLocation.getX();
            int cannonY = fakeCannonLocation.getY();
            Npc[] npcsToAttack = new Npc[npcsInArea.Count];
            bool hit = false;
            foreach (Npc n in Server.getNpcList())
            {
                hit = false;
                Location l = n.getLocation();
                if (n == null || n.isHidden() || n.isDead() || !n.getLocation().withinDistance(fakeCannonLocation, 8))
                {
                    continue;
                }
                switch (direction)
                {
                    case 0: // North
                        hit = l.inArea(cannonX - 1, cannonY, cannonX + 1, cannonY + 8);
                        break;

                    case 1: // North east
                        break;

                    case 2: // East:
                        hit = l.inArea(cannonX, cannonY - 1, cannonX + 8, cannonY + 1);
                        break;

                    case 3: // South east
                        break;

                    case 4: // South
                        hit = l.inArea(cannonX - 1, cannonY - 8, cannonX + 1, cannonY);
                        break;

                    case 5: // South west
                        break;

                    case 6: // West
                        hit = l.inArea(cannonX - 8, cannonY - 1, cannonX, cannonY + 1);
                        break;

                    case 7: // North west
                        break;
                }
                if (hit)
                {
                    Npc npc = n;
                    p.getPackets().sendProjectile(fakeCannonLocation, n.getLocation(), 30, 53, 50, 38, 38, 40, n);
                    Event doCannonHitEvent = new Event(1000);
                    doCannonHitEvent.setAction(() =>
                    {
                        doCannonHitEvent.stop();
                        int damage = Misc.random(30);
                        p.getSkills().addXp(Skills.SKILL.RANGE, damage * 2);
                        npc.hit(damage);
                        npc.setLastAnimation(new Animation(npc.getDefenceAnimation()));
                    });
                    Server.registerEvent(doCannonHitEvent);
                    return true;
                }
            }
            return false;
        }
Esempio n. 30
0
 public void confirmOffer()
 {
     if (currentOffer == null)
     {
         return;
     }
     if (currentOffer is BuyOffer)
     {
         int gpAmount = currentOffer.getTotalAmount() * currentOffer.getPriceEach();
         if (currentOffer.getTotalAmount() <= 0)
         {
             p.getPackets().sendMessage("You must choose the quantity you wish to buy!");
             return;
         }
         else if (!p.getInventory().hasItemAmount(995, gpAmount))
         {
             p.getPackets().sendMessage("You don't have enough coins in your inventory to cover the offer.");
             return;
         }
         else if (!p.getInventory().deleteItem(995, gpAmount))
         {
             return;
         }
     }
     else if (currentOffer is SellOffer)
     {
         if (currentOffer.getTotalAmount() <= 0)
         {
             p.getPackets().sendMessage("You must choose the quantity you wish to sell!");
             return;
         }
         else if (!p.getInventory().hasItemAmount(currentOffer.getItem(), currentOffer.getTotalAmount()))
         {
             p.getPackets().sendMessage("You do not have enough of this item in your inventory to cover the offer.");
             return;
         }
         if (ItemData.forId(currentOffer.getItem()).isNoted() || ItemData.forId(currentOffer.getItem()).isStackable())
         {
             if (!p.getInventory().deleteItem(currentOffer.getItem(), currentOffer.getTotalAmount()))
             {
                 return;
             }
         }
         else
         {
             //UnNoted variant of this item, so remove multiple items from inventory.
             int i = 0;
             for (int j = 0; j < currentOffer.getTotalAmount(); j++)
             {
                 if (!p.getInventory().deleteItem(currentOffer.getUnNotedId()))
                 {
                     currentOffer.setTotalAmount(i);
                     p.getPackets().sendConfig(1110, currentOffer.getTotalAmount());
                     break;
                 }
                 i++;
             }
         }
     }
     p.getPackets().sendConfig(1113, -1);
     p.getPackets().sendConfig(1112, -1);
     currentOffer.setProgress(currentOffer.getSubmittingId());
     p.getPackets().updateGEProgress(currentOffer);
     Server.getGrandExchange().addOffer(currentOffer);
     GEItem offer = currentOffer;
     currentOffer = null;
     Event updateGEProgressEvent = new Event(500);
     updateGEProgressEvent.setAction(() =>
     {
         updateGEProgressEvent.stop();
         offer.setProgress(offer.getOrangeBarId());
         p.getPackets().updateGEProgress(offer);
     });
     Server.registerEvent(updateGEProgressEvent);
 }